www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/CalculatingMaximumMeanAndStandardDeviationExample.m
%% Calculating Maximum, Mean, and Standard Deviation % This example shows how to use MATLAB functions to calculate the maximum, % mean, and standard deviation values for a 24-by-3 matrix called count. % MATLAB computes these statistics independently for each column in the matrix. % Copyright 2015 The MathWorks, Inc. %% Do a bunch of setup stuff % Load the sample data load count.dat % Find the maximum value in each column mx = max(count) % Calculate the mean of each column mu = mean(count) % Calculate the standard deviation of each column sigma = std(count) %% Step 2 % 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: % 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. [mx,indx] = max(count) %% Step 3 % 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: min(count(:))