MatLab Programming
Functions
Single Output function
function out =fnName(param1, param 2...)
...body
end
Multi Output function
function [out1, out2, ..] =fnName(param1, param 2...)
...body
end
eg:
function y = squareThisNumber(x)
y= x^2
// Multiple Output
function [y1,y2] = squareAndCubeThisNumber(x)
y1= x^2
y2= x^3
Anonymous function
-
Returns only single output
-
Can be pass as input to other function
-
f is called Function Handle
f = @(params..) expression
