Not enough input argument in ode45

조회 수: 1(최근 30일)
Rishabh Mankotia
Rishabh Mankotia 2022년 5월 21일
댓글: VBBV 2022년 5월 21일
function dxdt = mastersystem(t,x);
b = -.68;
a= -1.27;
c= abs(x(1)+1);
d= abs(x(1)-1);
e= abs(x(4)+1);
g= abs(x(4)-1);
f1= b*x(1)+.5*(a-b)*(c-d);
f4= b*x(4)+.5*(a-b)*(e-g);
w(t)= 0.1*sin(2*t);
dxdt(1,1)= -10*x(1)+ 10*x(2)-10*f1+w(t);
dxdt(2,1)= x(1)-1.02*x(2)+x(3)+.02*x(5);
dxdt(3,1)=-14.87*x(2);
dxdt(4,1)=-10*x(4)+10*x(5)-10*f4+w(t);
dxdt(5,1)= x(4)-x(5)+x(6);
dxdt(6,1)= -14.87*x(5);
y(1)=x(1);
y(2)=x(3);
y(3)=x(4);
y(4)=x(5);
y(1)=x(1);
y(2)=x(3);
y(3)=x(4);
y(4)=x(5);
[t,x] = ode45(mastersystem,[0 10],[0 0 0 0 0 0]);
Not enough input arguments.
Error in mastersystem (line 4)
c= abs(x(1)+1);

답변(1개)

VBBV
VBBV 2022년 5월 21일
편집: VBBV 2022년 5월 21일
[t,x] = ode45(@mastersystem,[0 10],[0 0 0 0 0 0]); % use a function handle to pass function as argument
plot(t,x)
function dxdt = mastersystem(t,x);
b = -.68;
a= -1.27;
c= abs(x(1)+1);
d= abs(x(1)-1);
e= abs(x(4)+1);
g= abs(x(4)-1);
f1= b*x(1)+.5*(a-b)*(c-d);
f4= b*x(4)+.5*(a-b)*(e-g);
w = 0.1*sin(2*t); % change this vector assignment
dxdt(1,1)= -10*x(1)+ 10*x(2)-10*f1+w;
dxdt(2,1)= x(1)-1.02*x(2)+x(3)+.02*x(5);
dxdt(3,1)=-14.87*x(2);
dxdt(4,1)=-10*x(4)+10*x(5)-10*f4+w;
dxdt(5,1)= x(4)-x(5)+x(6);
dxdt(6,1)= -14.87*x(5);
y(1)=x(1);
y(2)=x(3);
y(3)=x(4);
y(4)=x(5);
y(1)=x(1);
y(2)=x(3);
y(3)=x(4);
y(4)=x(5);
end
  댓글 수: 1
VBBV
VBBV 2022년 5월 21일
use a function handle to pass function as argument

댓글을 달려면 로그인하십시오.

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by