Not enough input argument in ode45

1 visualización (últimos 30 días)
Rishabh Mankotia
Rishabh Mankotia el 21 de Mayo de 2022
Comentada: VBBV el 21 de Mayo de 2022
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);

Respuestas (1)

VBBV
VBBV el 21 de Mayo de 2022
Editada: VBBV el 21 de Mayo de 2022
[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 comentario
VBBV
VBBV el 21 de Mayo de 2022
use a function handle to pass function as argument

Iniciar sesión para comentar.

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by