Thursday, January 27, 2005

Tips of Programming

It is a powerful research assistance tool with various functions and tookits, so the best way to grasp Matlab is to use it. Write down the tips you dicover or learn yourself, and after a while you will find yourself an expert of Matlab.

1 Comments:

Blogger Shunkai Fu said...

Deal With the Input and Output Arguments
- Use nargin and nargout to determine the number of input and output arguments.
- Use the nargchk and nargoutchk to verify the number of input and output arguments.
- Example (find the minimum number)
function [x,y,z] = myarg(a, b, c, d)
disp(nargchk(2, 4, nargin)) % Allow 2 to 4 inputs
disp(nargoutchk(0,2,nargout)) % Allow 0 to 2 ouputs

x = a;
if (a > b)
x = b;
end
if nargin == 4
y = c;
if (c > d)
y = d;
end
z = x;
if x > y
z = y;
end
else
y = x;
z = x;
end

January 27, 2005 at 5:28:00 PM PST  

Post a Comment

<< Home