Solving system of equations

3 Ansichten (letzte 30 Tage)
Rasto
Rasto am 24 Mär. 2013
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);

Akzeptierte Antwort

Walter Roberson
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
Rasto
Rasto am 24 Mär. 2013
Thank you for your answer, but I do not know how to think. Can I please give you the example?
Walter Roberson
Walter Roberson am 24 Mär. 2013
solE=solve(subs(eqnE1), subs(eqnE2), 'xEsol, yEsol');
xxE = double(solE.xEsol);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

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!

Translated by