Collect does not do the job
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohammad Shojaei Arani
am 23 Nov. 2021
Kommentiert: Mohammad Shojaei Arani
am 24 Nov. 2021
Dear friends,
I have a simple question but after spending an hour I could not figur out how to fix it. So, apologies if this is a simple problem for you. As you see in bellow, I would like to write the following expression in a more compact way:
syms y y0 muY(y) dt
f=(y*diff(muY(y), y, y) - y0*diff(muY(y), y, y) + 2*muY(y)^2 + 2*diff(muY(y), y) + 2*y*muY(y)*diff(muY(y), y) - 2*y0*muY(y)*diff(muY(y), y))/dt;
More clearly, I need to re-write f in terms of (y-y0). As you see, we can do it as bellow (the command collect(f,y-y0) does not work, unfortuantely. Also, the rewrite command is limitted to soem special target functions):
f=((y-y0)*diff(muY(y), y, y) + 2*muY(y)^2 + 2*diff(muY(y), y) + 2*(y-y0)*muY(y)*diff(muY(y), y) )/dt;
which is a much nicer representation for the calculations I need to do.
Any idea?
Thanks in advance!
Babak
0 Kommentare
Akzeptierte Antwort
Paul
am 23 Nov. 2021
Here is one approach showing step-by-step. Many could be combined. Maybe there is a simpler way?
syms y y0 muY(y) dt
f=(y*diff(muY(y), y, y) - y0*diff(muY(y), y, y) + 2*muY(y)^2 + 2*diff(muY(y), y) + 2*y*muY(y)*diff(muY(y), y) - 2*y0*muY(y)*diff(muY(y), y))/dt
syms D2Y DY
f = subs(f,diff(muY,y,2),D2Y)
f =subs(f,diff(muY,y),DY)
[numf,denf] = numden(f)
syms dely
numf = subs(numf,y,dely + y0)
numf = simplify(numf)
numf = subs(numf,dely+y0,y)
numf = subs(numf,DY,diff(muY))
numf = subs(numf,D2Y,diff(muY,y,2))
numf = subs(numf,dely,y-y0)
f = numf/denf
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!