MATLAB: Solving system of equations

quadratic equationssystem of equations

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);

Best Answer

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().