The second input to coder.inte​rnal.reall​ocDynamicM​atrix must be indexInt.

I want to use ode45 in matlab function(that is block of sumulink).
However, i cannot do it when i tried to use ode45 for solve second‐order differential equation.
Would you tell me how to use ode45 in matlab function?
i tried the following code.
function yout = fcn(u)
[t,y] = ode45(@vdp1,[0 20],[2; 0]);
yout = y(end,:);
end
function dydt = vdp1(t,y)
dydt = [y(2); (1-y(1)^2)*y(2)-y(1)];
end

Answers (0)

Products

Release

R2021b

Asked:

on 12 Dec 2022

Community Treasure Hunt

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

Start Hunting!