- Case 1. Same m file. Call it yield.m
How to call a function inside other function in a equation?
1 view (last 30 days)
I have one function function B=magnetic flux(x)
Now I have to call B in other function function y=yield(x)
where y= x(1)*e^-B where B is magnetic flux
How to do it without writing the equation of B in second function
Yongjian Feng on 25 Jan 2022
Edited: Yongjian Feng on 25 Jan 2022
It depends on whether you need to use B in anywhere else. If B is only used in your function yield, you can put it in the same m file, otherwise create a separate file for B.
B = magnetic_flux(x);
% internal function
2. Case 2. Two m files. Put yield function in yield.m, and magnetic_flux function in magnetic_flux.m.