I want to treat w as a constant
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
syms y(x)
ode = diff(y,x,2) +2*diff(y,x) +(w^2+1)*y == 0;
Dy = diff(y);
cond1 = y(0) == 1
cond2 = Dy(0) == 0
conds = [cond1 cond2]
ySol(x) = dsolve(ode,conds);
ySol = simplify(ySol)
the answer is
exp(-x)*(cos(wx)+1/w*sin(wx))
how can I get the answer?
0 Kommentare
Antworten (2)
David Goodmanson
am 31 Okt. 2021
Hello HJ,
try replacing the first line with
syms y(x) w real
in which case the result is
ySol(x) =
(exp(-x)*(sin(w*x) + w*cos(w*x)))/w
0 Kommentare
Walter Roberson
am 31 Okt. 2021
syms y(x)
syms w real
ode = diff(y,x,2) +2*diff(y,x) +(w^2+1)*y == 0;
Dy = diff(y);
cond1 = y(0) == 1;
cond2 = Dy(0) == 0;
conds = [cond1 cond2]
ySol(x) = dsolve(ode,conds);
ySol = simplify(ySol)
To get from that to what you want is sightly tricky. MATLAB has "preferred" ways to express terms, and you need to force it to overwride that preferred forms. That is, the output is already equivalent to what you want, but to force it to be written the same way you want you need to take a couple of steps that are not obvious.
ch = children(ySol(x));
ch{2}*expand(ch{1}*ch{3})
0 Kommentare
Siehe auch
Kategorien
Mehr zu Linear Algebra finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!