フィルターのクリア

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

2 ビュー (過去 30 日間)
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

採用された回答

Torsten
Torsten 2022 年 7 月 17 日
[t,x]=ode45(@f,ts,xo);
instead of
[t,x]=ode45(f,ts,xo);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by