Insufficient input arguments. continues to come out. Help

1 view (last 30 days)
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);

Answers (1)

Voss
Voss on 28 Mar 2022
Try changing this:
[t , y]= ode23(odefun, tspan, y);
to this:
[t , y]= ode23(@odefun, tspan, y);

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!