I have made different functions as separate .m files and i want to include or call all these functions or .m files in my main .m file please any help?

 Accepted Answer

Make sure that:
Then you can simply call the function from any script or function, just like you would any other function. It really is that simple.
Here is an example:
function out = myfun(x,y)
out = x^2 - y^3;
end
and I save this using the filename myfun.m, then I can call it like this, from any other function or script:
a = 1;
b = 2;
val = myfun(a,b)

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products

Asked:

zz
on 20 Jan 2016

Commented:

on 6 Mar 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!