ode45 command syntax error

1 visualización (últimos 30 días)
Thomas Holmes
Thomas Holmes el 16 de Abr. de 2019
Comentada: Thomas Holmes el 16 de Abr. de 2019
I am trying to use ode45 to plot this differential (dy/dx)= -0.00043y with this intial condition y(0)=1 on the interval [0 30000]. I tried to use this code but I just get the following error message.
[x5,y5]=ode45(@(y) -0.00043*y ,[0 30000],1)
Error using HW07Prob2>@(y)-0.00043*y
Too many input arguments.
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in HW07Prob2 (line 10)
[x5,y5]=ode45(@(y) -0.00043*y ,[0 30000],1);
Can someone help me figure out what I am doing wrong?

Respuesta aceptada

Walter Roberson
Walter Roberson el 16 de Abr. de 2019
Your ode anonymous function must accept both y and y. @(t,y). You do not need to pass t into your actual function.
  1 comentario
Thomas Holmes
Thomas Holmes el 16 de Abr. de 2019
Thank you, I realized this shortly after posting.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by