Filter löschen
Filter löschen

I'm having trouble with ode45. It keeps getting the "not enough input arguments" error.

1 Ansicht (letzte 30 Tage)
I'm trying to solve the problem 3.10.1 from the book Engineering Vibrations, from Inman, but I keep getting the ''not enough input arguments'' error for reasons I don't understand. My code being:
clear
xo=[0.01 1];
ts=[0,8];
[t,x]=ode45(f,ts,xo);
Not enough input arguments.

Error in solution>f (line 14)
v=[x(2); x(2).*-2*zeta*wn + x(1).*-wn^2 - x(1)^3.*alpha + Fo/m*(stepfun(t,t1)-stepfun(t,t2))];
plot(t, x(:,1)); hold on % The response of nonlinear system
[t,x]=ode45(f1,ts,xo);
plot(t,x(:,1),'——'); hold off % The response of linear system
%---------------------------------------------
function v= f(t,x)
m=100; k=2000; c=20; wn=sqrt(k/m); zeta=c/2/sqrt(m*k); Fo=1500;
alpha=3; t1=1.5; t2=5;
v=[x(2); x(2).*-2*zeta*wn + x(1).*-wn^2 - x(1)^3.*alpha + Fo/m*(stepfun(t,t1)-stepfun(t,t2))];
end
%---------------------------------------------
function v= f1(t,x)
m=100; k=2000; c=20; wn=sqrt(k/m); zeta=c/2/sqrt(m*k); Fo=1500;
alpha=0; t1=1.5; t2=5;
v=[x(2); x(2).*-2*zeta*wn + x(1).*-wn^2 - x(1)^3.*alpha+ Fo/m*(stepfun(t,t1)-stepfun(t,t2))];
end

Akzeptierte Antwort

Torsten
Torsten am 17 Jul. 2022
[t,x]=ode45(@f,ts,xo);
instead of
[t,x]=ode45(f,ts,xo);

Weitere Antworten (0)

Kategorien

Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by