%I have this function script, created and saved with no mistakes. When I try to solve the ODE, using ode45 it does not work, I get this:
Error using feval
Undefined function 'govequ' 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 113)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0,
odeArgs, odeFcn, ...
Here, the function script:
function y_dot = govequ(t,y)
y_dot = -t^2-4*y;
end
And here the command I use to solve it:
[ts,ys] = ode45(@govequ, [0,10], 1)

1 comentario

Walter Roberson
Walter Roberson el 19 de Feb. de 2016
Your function govequ is not in govequ.m somewhere on the MATLAB path.

Iniciar sesión para comentar.

 Respuesta aceptada

Star Strider
Star Strider el 19 de Feb. de 2016

1 voto

This works for me (in R2015a):
govequ = @(t,y) -t.^2-4*y;
[ts,ys] = ode45(govequ, [0,10], 1);
figure(1)
plot(ts, ys)
grid

2 comentarios

George Schwarzenneger
George Schwarzenneger el 20 de Feb. de 2016
I need a function file, anyways, I saw the problem. Thank you
Star Strider
Star Strider el 20 de Feb. de 2016
My pleasure.

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 19 de Feb. de 2016

Comentada:

el 20 de Feb. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by