WHY do I get this error

1 visualización (últimos 30 días)
mahesh tom
mahesh tom el 17 de Nov. de 2017
Comentada: asavra siddiqui el 10 de Abr. de 2021
function dydt = free25(t,y);
g = 9.81;
l = 1;
dydt = [y(2);-g/l.*sin(y(1))];
end
[t,y]= ode45('free25',[0 10],[0 0.09]);%I typed this in command window
plot(t,y(:,1));
refline([0 0]);
Error using feval Undefined function 'free25' for input arguments of type 'double'.
Error in odearguments (line 87) 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);

Respuesta aceptada

Mischa Kim
Mischa Kim el 17 de Nov. de 2017
Editada: Mischa Kim el 17 de Nov. de 2017
mahesh, is the above code all in one and the same script? If it is modify like this:
[t,y]= ode45(@free25,[0 10],[0 0.09]);%I typed this in command window
plot(t,y(:,1))
function dydt = free25(t,y)
g = 9.81;
l = 1;
dydt = [y(2);-g/l.*sin(y(1))];
end
Another option would be to store the first part of the script (first two commands) in one function and the second part in a different function. For this second option make sure you name the file the same way you name the function: free25.m
  4 comentarios
mahesh tom
mahesh tom el 17 de Nov. de 2017
Editada: mahesh tom el 17 de Nov. de 2017
Thank you! The problem was that the file was not on the MATLAB search path!
asavra siddiqui
asavra siddiqui el 10 de Abr. de 2021
I have the same problem with my code how can I put it on MATLAB search path

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by