Not enough input argument in ode45
1 回表示 (過去 30 日間)
古いコメントを表示
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);
0 件のコメント
回答 (1 件)
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
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!