Text-only Table of Contents (frame/ no frame)
(18) Function_Details Previous Top Next

Structure of a Function M-File



Example of a function:

function y = mymean(x)
%MYMEAN Average or mean value.
%   For vectors, MYMEAN(X) is the
mean value of the elements in X. For
%   matrices, MYMEAN(X)is a row vector containing the mean value of
%   each column. For N-D arrays, MYMEAN(X) is the mean value of the
%   elements along the first non-singleton dimension of X.
[m,n]=size(x);
if m==1
     m=n;
end
y=sum(x)/m;


Required
Optional
Command Line Syntax
Try:
>> a=rand(5);
>> b=mymean(a)










Previous Top Next


Function_Details.src  last modified Oct 17, 2007 Introduction Table of Contents
(frame/no frame)
Printable
(single file)
© Dartmouth College