{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

data analysis

data analysis - MATLAB Data Analysis Greg Reese Ph.D...

This preview shows pages 1–19. Sign up to view the full content.

MATLAB Data Analysis Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
3 Data analysis MATLAB has functions for the basic statistical analysis of numbers stored in a vector. The table that follows shows some of them. For more details, type help datafun at the command line.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 Basic statistics max Largest component. min Smallest component. mean Average or mean value. median Median value. std Standard deviation. var Variance. sum Sum of elements. prod Product of elements. hist Histogram.
5 Basic statistics Example Class’s quiz grades: 2, 9, 8, 5, 4, 5, 8, 10, 8, 7 Store grades in vector and compute the average quiz score: >> grades = [2 9 8 5 4 5 8 10 8 7]; >> mean(grades) ans = 6.6000

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 Basic statistics Try It Make a vector of a class’s quiz grades: 2, 9, 8, 5, 4, 5, 8, 10, 8, 7 Compute the mean, minimum, maximum, median, and mode Show the number of grades
7 Basic statistics Try It >> grades = [ 2 9 8 5 4 5 8 10 8 7 ]; >> mean(grades) ans = 6.6000 >> min(grades) ans = 2 >> max(grades) ans = 10

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
8 Basic statistics Try It >> grades = [ 2 9 8 5 4 5 8 10 8 7 ]; >> median(grades) ans = 7.5000 >> mode(grades) ans = 8 >> length( grades ) % number of grades ans = 10
9 Basic statistics Can also compute statistics on matrices. For two-dimensional matrices MATLAB operates on each column separately. This produces a row vector whose length is the number of columns in the original matrix.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
10 Basic statistics Example Class’s quiz grades on one Friday (column 1) and on the following Friday (column 2): >> grades = [2 9 8 5 4 8 10; 4 9 9 2 1 4 6]' grades = 2 4 9 9 8 9 5 2 4 1 8 4 10 6
11 Basic statistics Example >> mean( grades ) ans = 6.5714 5.0000 >> min( grades ) ans = 2 1 >> max( grades ) ans = 10 9

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
12 Basic statistics Two ways to compute a statistic on all of the data. In first, apply function twice. Example >> mean( mean( grades ) ) ans = 5.7857 >> min( min( grades ) ) ans = 1 >> max( max( grades ) ) ans = 10
13 Basic statistics Second way - convert matrix to 1D, then compute statistic If M is a matrix (of any dimension), M(:) produces a one-dimensional column vector Both have same number of elements M(:) made by stacking columns up, i.e., concatenating second column under first, third column under second, etc.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
14 Basic statistics Example >> m1 = [ 1 2 3; 4 5 6] m1 = 1 2 3 4 5 6 >> m2 = m1(:) m2 = 1 4 2 5 3 6
15 Basic statistics Example >> m1 = [ 1 2 3; 4 5 6] m1 = 1 2 3 4 5 6 >> mean( m1 ) ans = 2.5000 3.5000 4.5000 >> mean( m1(:) ) ans = 3.5000 >> mean( mean(m1) ) ans = 3.5000

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
16 Basic statistics Try It >> m1 = [ 1 2 3; 4 5 6]; Compute the minimum and maximum of all elements in m1 using the m1(:) notation >> min( m1(:) ) ans = 1 >> max( m1(:) ) ans = 6
17 Basic statistics Caution - depending on the statistic, the two methods may not be the same Try It >> m1 = [ 1 2 3; 4 5 6]; Compute the standard deviation both ways using std() >> std( std( m1 ) ) ans = 0 >> std( m1(:) ) ans = 1.8708 Wuz up?

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
18 Basic statistics Can also take statistics along rows by putting in second parameter of "2", e.g.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 73

data analysis - MATLAB Data Analysis Greg Reese Ph.D...

This preview shows document pages 1 - 19. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online