필터 지우기
필터 지우기

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 CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by