Handling constant names for ODE solutions
Ältere Kommentare anzeigen
So, I try to solve symbolycally a variational problen of finding minima for a given functional. But I can't handle names of constants while solving Euler's equation. when changing function F, constants enumerate differently and i don't know how to keep them in place/
clc
syms x y Dy D2y
F= x + y^2 + Dy^2;
x1=0;
y1=1;
x2=1;
y2=3;
phi= -x^2 + 4;
fprintf('F(x,y,y'')=%s\n',char(F))
fprintf('Boundary cond. on left side: y(%d)=%d\n',x1,y1)
fprintf('Boundary cond. on right side: y(%d)=%d\n',x2,y2)
fprintf('Right side restrictions: y=%s\n',char(phi))
dFdy=diff(F,y);
dFdy1=diff(F,Dy);
d_dFdy1_dx=diff(dFdy1,x);
d_dFdy1_dy=diff(dFdy1,y);
d_dFdy1_dy1=diff(dFdy1,Dy);
dFy1dx=d_dFdy1_dx+d_dFdy1_dy*Dy+d_dFdy1_dy1*D2y;
Euler=simplify(dFdy-dFy1dx);
deqEuler=[char(Euler) '=0'];
Sol=dsolve(deqEuler,'x');
if length(Sol)~=1
error('No solutions (or more then 1)!');
end
SolLeft=subs(Sol,x,x1);
SolRight=subs(Sol,x,x2);
EqLeft=[SolLeft == sym(y1)] % =y1
EqRight=[SolRight == sym(y2)]; % =y2
syms C1 C2
Con=solve([EqLeft EqRight],[C1 C2]);
So, plugging for example F = -y^2 + Dy^2 gives me system with C6 and C7 that pop out of nowhere instead of C1 and C2. Why is this so?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!