Insufficient input arguments. continues to come out. Help

2.187
%This progrem will use dfuncl.m
tspan = 0: 0.05: 8;
y = [0.4; 0;0];
[t , y]= ode23(odefun, tspan, y);
plot (t, y(:, 1));
xlabel ('t');
ylabel ('y(1');
title ('problem 2.187');
function f = odefun( ~ , y )
u = 0.5;
k = 100;
m = 5;
f=zeros(2,1);
f(1) = y(2);
f(2) = -u*9.81*sign(y(2))-k*y(1)/m;
end
-------------------------------------------------------------------
>> pr187
Insufficient input arguments.
an error occurred : pr187>odefun (16. line)
f(1) = y(2);
an error occurred: pr187 (5. line )
[t , y]= ode23(odefun, tspan, y);

Réponses (1)

Try changing this:
[t , y]= ode23(odefun, tspan, y);
to this:
[t , y]= ode23(@odefun, tspan, y);

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by