how to use nested functions in simulink
古いコメントを表示
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 件のコメント
Walter Roberson
2019 年 7 月 11 日
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
2019 年 7 月 17 日
Hetvi Patel
2020 年 3 月 21 日
hello hamid ,i am facing the same problem.Did you find a solution for it?
Hetvi Patel
2020 年 3 月 21 日
[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
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!