Solving system of equations
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Walter Roberson
il 24 Mar 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 Commenti
Walter Roberson
il 24 Mar 2013
solE=solve(subs(eqnE1), subs(eqnE2), 'xEsol, yEsol');
xxE = double(solE.xEsol);
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!