필터 지우기
필터 지우기

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 CenterFile Exchange에서 Numerical 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