Error using sym/subsindex (line 853)
Show older comments
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
Answers (2)
Sulaymon Eshkabilov
on 27 May 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)]
cond = y(0) == [a;c]
ySol(t) = simplify(subs(y,dsolve(ode,cond)))
Categories
Find more on Equation Solving in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
