MATLAB: How to call to function from other function

matlab function

Hi guys, Im building two function with I call one of them from another function, so how can I call the other function in matlab? just write its name where I want to implement it?
I mean lets assume Im building two functions one called func1, the other function called func2 .. I want to call in the func1 to the func2 so what should I write inside the implemenation of func1 .. just func2 and then matlab compiler will call to the other implementation of func2? thanks alot.

Best Answer

You need to save both the function files in the same folder and yes call the other function in the required function. It is very simple. Check the below example.
function val = thesum(a,b)
val = a+b ;
end
Now call the above function inisde another function.
function val = theproduct(a,b)
c = thesum(a,b) ;
val = c*a*b ;
end