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

Info iconThis preview shows pages 1–18. Sign up to view the full content.

View Full Document Right Arrow Icon
MATLAB Data Analysis Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University
Background image of page 1

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

View Full DocumentRight Arrow Icon
MATLAB Data Analysis © 2010 Greg Reese. All rights reserved 2
Background image of page 2
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.
Background image of page 3

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

View Full DocumentRight Arrow Icon
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.
Background image of page 4
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
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 6
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
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 8
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.
Background image of page 9

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

View Full DocumentRight Arrow Icon
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
Background image of page 10
11 Basic statistics Example >> mean( grades ) ans = 6.5714 5.0000 >> min( grades ) ans = 2 1 >> max( grades ) ans = 10 9
Background image of page 11

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

View Full DocumentRight Arrow Icon
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
Background image of page 12
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.
Background image of page 13

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

View Full DocumentRight Arrow Icon
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
Background image of page 14
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
Background image of page 15

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

View Full DocumentRight Arrow Icon
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
Background image of page 16
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?
Background image of page 17

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

View Full DocumentRight Arrow Icon
Image of page 18
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 11/04/2011 for the course MME 414 at Miami University.

Page1 / 73

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online