フィルターのクリア

Using ode45 Simulink - Anonymous Functions

2 ビュー (過去 30 日間)
rantunes
rantunes 2015 年 4 月 20 日
回答済み: Navaneeth Raman 2015 年 4 月 21 日
Hey,
I am new in Simulink and tried to migrate (with some necessary modifications) a code I made in Matlab into Simulink to have a model-based approach.
However I am having issues with the implementation of ode45. I attach a prt screen that shows the issue and I don't understand neither how to solve it. I understand that I can't have anonymous functions but I don't know how to avoid this if I have to use the ode45 function.
Someone please can help me?
Thanks, Rodrigo

回答 (1 件)

Navaneeth Raman
Navaneeth Raman 2015 年 4 月 21 日
Hi,
Anonymous functions are not supported for code generation. Create another function that defines the differential equation and call it using the function handle in the ode45 function. For example, lets say that I have defined my differential equation like this:
function dy = rigid(t,y)
dy = zeros(3,1); % a column vector
dy(1) = y(2) * y(3);
dy(2) = -y(1) * y(3);
dy(3) = -0.51 * y(1) * y(2);
end
Then use the ode45 solver function to call this function:
ode45(@rigid,timspan,initial conditions)
HTH, Navaneeth

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by