Text-only Table of Contents (frame/ no frame)
(22) 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) returns the
%mean value. For matrices, mymean(x)
% is a row vector containing the mean
% value of each column.
[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 Sep 29, 2009 Introduction Table of Contents
(frame/no frame)
Printable
(single file)
© Dartmouth College