Subs function not working as expected
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Patricio Whittingslow
el 25 de Sept. de 2018
Comentada: Patricio Whittingslow
el 25 de Sept. de 2018
I've come across an unexpected result. Symbolic equation substitution is yielding wrong result. Below is my code.I've tried reset(symengine) but it doesen't seem to help.
syms y real
Tsym = ...
(204800*y)/7 - (19342813113834066795298816*y^2)/661131307601750375 + 60;
Tfunc=@(y) ...
(204800*y)/7 - (19342813113834066795298816*y^2)/661131307601750375 + 60;
H=0.0005;
y=H;
symval=subs(Tsym);
funcval=Tfunc(H);
if funcval~=symval
fprintf('Something is wrong. \n')
end
0 comentarios
Respuestas (1)
Bish Erbas
el 25 de Sept. de 2018
Code below works for me. You defined the H and y variables after defining the symbolic equations. Move the variable definition at the beginning of your code.
syms y real
H=0.0005;
y=H;
Tsym = ...
(204800*y)/7 - (19342813113834066795298816*y^2)/661131307601750375 + 60;
Tfunc=@(y) ...
(204800*y)/7 - (19342813113834066795298816*y^2)/661131307601750375 + 60;
symval=subs(Tsym);
funcval=Tfunc(H);
if funcval~=symval
fprintf('Something is wrong. \n')
end
Ver también
Categorías
Más información sobre Assumptions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!