Hello, I have some problem with my matlab code. I would like to use ode45, but the program gives me the error:
"Not enough input arguments.
Error in file>odefun (line 24)
dydt=5*y
Error in file (line 20)
[t,y] = ode45(odefun,tspan,y0)"
can you help me?
Thanksssss!!!
Ts = 1;
tspan=[0:Ts:10]; % time scale
y0=1; %initial condition
[t,y] = ode45(odefun,tspan,y0)
function dydt = odefun(t,y)
dydt = zeros (2,1)
dydt(1) = y(2);
dxdt(2) = -3*y(1);
end

 Respuesta aceptada

Walter Roberson
Walter Roberson el 19 de Mayo de 2019

1 voto

[t,y] = ode45(@odefun,tspan,y0)

5 comentarios

Michela Longhi
Michela Longhi el 19 de Mayo de 2019
Thanks for your answer, but if I use
[t,y] = ode45(@odefun,tspan,y0)
the program gives another error :(
"Attempt to execute SCRIPT ode45 as a function:
C:\Users\Michela\Desktop\Systems\ode45.m
Error in file (line 20)
[t,y] = ode45(@odefun,tspan,y0)"
why?
John D'Errico
John D'Errico el 19 de Mayo de 2019
Don't name the script you put your code in ODE45.
Michela Longhi
Michela Longhi el 20 de Mayo de 2019
What does you mean? can you make an example, please?
Thanks
madhan ravi
madhan ravi el 20 de Mayo de 2019
It means that you have custom file named ode45.m which thwarts the inbuilt function of MATLAB‘s ode45(). So move your file from MATLAB‘s path or rename it.
Michela Longhi
Michela Longhi el 20 de Mayo de 2019
Thank you!!!! It's working now, my file was called file.m but in the same folder there was a file namer ode45.m that disturbed my script.

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 19 de Mayo de 2019

Comentada:

el 20 de Mayo de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by