Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Torsten
Torsten il 17 Lug 2022
[t,x]=ode45(@f,ts,xo);
instead of
[t,x]=ode45(f,ts,xo);

Più risposte (0)

Categorie

Scopri di più su Numerical Integration and Differential Equations in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by