Create a function called genStats that computes statistics f
Solution
The results are
To get the row numbers where the maximum data values occur in each data column, specify a second output parameter indx to return the row index. For example:
These results are
Here, the variable mx is a row vector that contains the maximum value in each of the three data columns. The variable indx contains the row indices in each column that correspond to the maximum values.
To find the minimum value in the entire count matrix, reshape this 24-by-3 matrix into a 72-by-1 column vector by using the syntax count(:). Then, to find the minimum value in the single column, use the following syntax:
Example 2 — Subtracting the Mean
Subtract the mean from each column of the matrix by using the following syntax:
Note: Subtracting the mean from the data is also called detrending. For more information about removing the mean or the best-fit line from the data, see Detrending Data.
Example: Using MATLAB Data Statistics
The Data Statistics dialog box helps you calculate and plot descriptive statistics with the data. This example shows how to use MATLAB Data Statistics to calculate and plot statistics for a 24-by-3 matrix, called count. The data represents how many vehicles passed by traffic counting stations on three streets.
This section contains the following topics:
Calculating and Plotting Descriptive Statistics
Formatting Data Statistics on Plots
Saving Statistics to the MATLAB Workspace
Generating Code Files
Note: MATLAB Data Statistics is available for 2-D plots only.
Calculating and Plotting Descriptive Statistics
Load and plot the data:
select Tools > Data Statistics .
The Data Statistics dialog box opens and displays descriptive statistics for the X- and Y-data of the Team 1 data set.
Select a different data set in the Statistics for list: Team 2.
This displays the statistics for the X and Y data of the Team 2 data set.
Select the check box for each statistic you want to display on the plot, and then click Save to workspace.
For example, to plot the mean of Station 2, select the mean check box in the Y column
| Note: Subtracting the mean from the data is also called detrending. For more information about removing the mean or the best-fit line from the data, see Detrending Data. |

