Solving system of equations

2 次查看(过去 30 天)
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);

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by