how to use nested functions in simulink
Show older comments
hello all,
I am using matlab function of simulink ,in my function some where needs the data from another function and when it gete this data it sends it to another one like below example
how can I implement this ?
thanks alot
function A = main function(a1,a2)
firsi_var =odeset(@func1,....)
second var= ode15s(@func2, first_var,...)
end
4 Comments
Walter Roberson
on 11 Jul 2019
Have your MATLAB Function Block call mainfunction
There are restrictions against using anonymous functions directly in MATLAB Function Block, but you can call a function that uses them.
You might possibly need to initialize first_var before assigning to it. Sometimes in Simulink it is easier to just create the structure directly instead of returning it from a function.
hamid
on 17 Jul 2019
Hetvi Patel
on 21 Mar 2020
hello hamid ,i am facing the same problem.Did you find a solution for it?
Hetvi Patel
on 21 Mar 2020
[Tv,ZV] = ode15s (fcn, t_v, ZV0, solver_options);
solver_options = odeset ('Mass', TM_Matrix, 'MassSingular', 'yes');
fcn = @(t,T) Thermomodel_fcnDAE(T, L_Matrix, Pv_Vektor, T_ref_Pv, T_K);
[Tv,ZV] = ode15s (fcn, t_v, ZV0, solver_options);
function dT = Thermomodel_fcnDAE(T, L_Matrix, Pv_Vektor, T_ref_Pv, T_K)
global count_fcn
global Pv_out
count_fcn = count_fcn + 1;
Pv_out = Pv_Vektor;
Pv_out(1) = Pv_Vektor(1)*(1+3.9/1000*(T(1)-T_ref_Pv));
Pv_out(2) = Pv_Vektor(2)*(1+3.9/1000*(T(2)-T_ref_Pv));
dT = L_Matrix * [T; T_K] + Pv_out;
end
THESE ARE MY EQUATIONS
Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!