Thursday 8 December 2011

Matlab Function creation | Matlab make Function with arguments and without arguments | Matlab function example

In Matlab toolbox ,we make a function very easy. You have use following steps to make a new function in matlab.
  1. Goto Matlab Editor window
  2. Press new M-File
  3. Type the function coding.
  4. Finally you have save the function as function name.
In matlab function contain 4 types
  1. Function with arguments
  2. Function without arguments
  3. No return values.
  4. 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...


Kindly Bookmark and Share it:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...