In Matlab toolbox ,we make a function very easy. You have use following steps to make a new function in matlab.
- Goto Matlab Editor window
- Press new M-File
- Type the function coding.
- Finally you have save the function as function name.
In matlab function contain 4 types
- Function with arguments
- Function without arguments
- No return values.
- Return Values.
Following example are explain these types.
Function with arguments
function add(a,b)
c = a+b;
display([Added values is : num2str(c)]);
add(10,12);% call a function
Function without arguments
function add()
a = 10;
b=20;
c = a+b;
display([Added values is : num2str(c)]);
simply call add();
No return values
This type of functions using both Function with arguments and without arguments.
Return Values
function c = add(a,b)
c = a+b;
display([Added values is : num2str(c)]);
c = add(10,20);% calling a function...
No comments:
Post a Comment