Subbing into a constant function in symbolic toolbox
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
All,
This doesn't work.
syms x y
f=3*y^2-2*y^3-3*x^2+6*x*y;
fx=diff(f,x);
fy=diff(f,y);
fxx=diff(f,x,2);
fyy=diff(f,y,2);
fxy=diff(diff(f,x),y);
S=solve(fx,fy);
FXX=subs(fxx,{x,y},{S.x,S.y});
H=fxx*fyy-fxy^2;
subs(H,{x,y},{S.x,S.y});
[S.x,S.y,FXX,H]
Wondering if it is a bug. The subs command in the symbolic toolbox does not produce a vector result when subbing a vector.
>> FXX=subs(fxx,{x,y},{S.x,S.y})
FXX =
-6
This should be a two by one vector with two -6's in it.
Is this a bug?
Workaround?
David.
1 comentario
bym
el 15 de Nov. de 2011
why do you think it is a bug? fxx = -6; there is nothing to substitute into?!?
Respuestas (1)
Abhishek Gupta
el 6 de Dic. de 2011
It does feel like a bug to me. I came up with a crude workaround/hack:
syms x y
f=3*y^2-2*y^3-3*x^2+6*x*y;
fx=diff(f,x);
fy=diff(f,y);
fxx=diff(f,x,2);
fyy=diff(f,y,2);
fxy=diff(diff(f,x),y);
S=solve(fx,fy);
% Add a variable which you do not expect to be in the calculation before substitution
syms z
FXX=subs(fxx+z,{x,y},{S.x,S.y})
FXX =
z - 6
z - 6
% Substitute zero for the variable to get your original calculation
FXX = subs(FXX,z,0)
FXX =
-6
-6
Hope this helps.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!