How to use Matlab function function

Step:
1, create a file .m, .m file with the following format keyword function defined functions, defined function:
function [Output Variable] = function name (input variable)

Input and output variables may be one or may be plural.

function [Output Variable] = function name (input variable)

% Notes

% Function body

2, when you save the .m file, be sure to save .m file functions to use the name.

For example as follows:

function [a,b,c]=test(d,e,f)

a = d + e.

b=e+f;

c=f+d;

end

Save the file as test.m file.

Calling the function:
[Q, W, E] = Test (l, 2,3)

Note: When the function call, not have to use letters when defining parameters used in the function. Such as

m1 = 1, m2 = 2, m3 = 3,

[h,j,k]=test(m1,m2,m3)

The same can be done custom test function calls right.

Guess you like

Origin blog.csdn.net/weixin_45176834/article/details/93996865