?? mean.m
字號:
function y = mean(x,dim) %函數(shù)定義行,注意函數(shù)名稱必須與文件名稱相同
%MEAN Average or mean value.——H1幫助行
% For vectors, MEAN(X) is the mean value of the elements in X. For
% matrices, MEAN(X) is a row vector containing the mean value of
% each column. For N-D arrays, MEAN(X) is the mean value of the
% elements along the first non-singleton dimension of X.——函數(shù)體說明
%
% MEAN(X,DIM) takes the mean along the dimension DIM of X.
%
% Example: If X = [0 1 2
% 3 4 5]
%
% then mean(X,1) is [1.5 2.5 3.5] and mean(X,2) is [1
% 4]
%
% See also MEDIAN, STD, MIN, MAX, COV.
% Copyright (c) 1984-98 by The MathWorks, Inc.
% $Revision: 5.13 $ $Date: 1997/11/21 23:23:55 $——注解
%函數(shù)主體
if nargin==1, %nargin指函數(shù)的輸入變量數(shù);nargout指函數(shù)的輸出變量數(shù)
% Determine which dimension SUM will use
dim = min(find(size(x)~=1));%size 求矩陣的行數(shù)與列數(shù),find找出非零元素的索引號
if isempty(dim), dim = 1; end
y = sum(x)/size(x,dim);
else
y = sum(x,dim)/size(x,dim);
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -