Error using sym/subsindex (line 853)

a = 2;
t=0:0.001:2;
b = 3;
c = -9;
d = 0;
syms y(t) il1(t) il2(t);
y(t) = [il1(t); il2(t)];
ode = diff(y(t),t) == [a b;c d]*[il1(t);il2(t)] + [d a;c b]*[b*heaviside(t) + d*cos(3*t);c*exp(-d*t)]
cond = y(0) == [a;c]
ySol(t) = dsolve(ode,cond)
Error using sym/subsindex (line 853) i get this error where did i do wrong

Réponses (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 27 Mai 2021
Hi,
Here is the corrected solution:
clearvars
a = 2;
b = 3;
c = -9;
d = 0;
syms t y(t) il1(t) il2(t);
y = [il1; il2];
Dy=diff(y,t);
EQN = Dy == [a b;c d]*[il1;il2] + [d a;c b]*[b*heaviside(t)+d*cos(3*t); c*exp(-d*t)]
cond = y(0) == [a;c]
ySol = dsolve(EQN, il1(0)==2, il2(0)==-9);
IL1 = ySol.il1
IL2 = ySol.il2
a = 2;
t=0:0.001:2;
b = 3;
c = -9;
d = 0;
syms y(t) il1(t) il2(t);
y(t) = [il1(t); il2(t)];
ode = diff(y(t),t) == [a b;c d]*[il1(t);il2(t)] + [d a;c b]*[b*heaviside(t) + d*cos(3*t);c*exp(-d*t)]
ode = 
cond = y(0) == [a;c]
cond = 
ySol(t) = simplify(subs(y,dsolve(ode,cond)))
ySol(t) = 

Catégories

En savoir plus sur Physics dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by