Solving system of equations
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
How to solve this task, where to calculate xE1, xE2, yE1, yE2?
Thanks in advance for any advice.
clear all; clc; close all;
CE=5; xC=1; yC=2; xD=3; yD=4;
eqnE1='CE^2=(xC-xEsol)^2+(yEsol-yC)^2';
eqnE2='(yEsol-yC)/(xC-xEsol)=(yC-yD)/(xD-xC)';
solE=solve(eqnE1, eqnE2, 'xEsol, yEsol');
xxE=eval(solE.xEsol);
yyE=eval(solE.yEsol);
xE1=xxE(1);
xE2=xxE(2);
yE1=yyE(1);
yE2=yyE(2);
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 24 Mär. 2013
When you use
eqnE1='CE^2=(xC-xEsol)^2+(yEsol-yC)^2';
then you are creating a string. The existing values CE and so on are not going to be substituted into that string.
You should not eval() a symbolic result, as symbolic results are not in MATLAB syntax. If you want to import values from the workspace (such as CE) then you should use subs(), possibly followed by double().
2 Kommentare
Walter Roberson
am 24 Mär. 2013
solE=solve(subs(eqnE1), subs(eqnE2), 'xEsol, yEsol');
xxE = double(solE.xEsol);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox 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!