Error using evalin Undefined function or variable 'x'. Error in sym/eval (line 11) s = evalin('ca​ller',vect​orize(map2​mat(char(x​))));

13 views (last 30 days)
i was trying to solve a simple system of equations, when the program gives me this error:
Error using evalin
Undefined function or variable 'x'.
Error in sym/eval (line 11)
s = evalin('caller',vectorize(map2mat(char(x))));
Error in es_6_analisi_cinematica (line 27)
xBposizioni=eval(solB.xBsol);
in fact when I go to evaluate the solutions of the system inside solB, it solves the system in x and y, rather than xBsol and yBsol. sorry that the script may seem strange but I'm Italian
i get the same problem using vpa instead of eval, the system of equations is solved with other variables, x and y
This is the script:
clear
AC=0.15;
BC=0.2;
AD=0.35;
xA=0;
yA=0;
rA=[xA yA 0];
xC=AC;
yC=0;
rC=[xC yC 0];
ii=0;
for phi=10^(-17):pi/36:2*pi
xD=AD*cos(phi);
yD=AD*sin(phi);
rD=[xD yD 0];
xBsol=sym('xBsol');
yBsol=sym('yBsol');
eqB1='xBsol*sin(phi)-yBsol*cos(phi)=0';
eqB2='(xC-xBsol)^2+yBsol^2-BC^2=0';
solB=solve(eqB1,eqB2,'xBsol','yBsol');
xBposizioni=eval(solB.xBsol);
yBposizioni=eval(solB.yBsol);
xB1=xBposizioni(1)
yB1=yBposizioni(1)
xB2=xBposizioni(2)
yB2=yBposizioni(2)
if (phi>=0 && phi<=pi)
if yB1>=0 xB=xB1;yB=yB1;
else
xB=xB2;yB=yB2;
end
end
if (phi>pi && phi< 2*pi)
if yB1<0
xB=xB1; yB=yB1;
else
xB=xB2; yB=yB2;
end
end
rB=[xB yB 0];
figure(1)
plot([xA,xB],[yA,yB],'k-',[xB, xC],[yB,yC],'r-',[xA,xC],[yA,yC],'b-',[xB,xD],[yB,yD],'g-')
text(xA,yA,'A')
text(xB,yB,'B')
text(xC,yC,'C')
text(xD,yD,'D')
hold on
xlim([-0.5 0.5])
ylim([-0.5 0.5])
end

Accepted Answer

Stephan
Stephan on 23 Nov 2020
Edited: Stephan on 23 Nov 2020
clear
AC=0.15;
BC=0.2;
AD=0.35;
xA=0;
yA=0;
rA=[xA yA 0];
xC=AC;
yC=0;
rC=[xC yC 0];
syms xBsol yBsol
ii=0;
for phi=10^(-17):pi/36:2*pi
xD=AD*cos(phi);
yD=AD*sin(phi);
rD=[xD yD 0];
eqB1=xBsol*sin(phi)-yBsol*cos(phi)==0;
eqB2=(xC-xBsol)^2+yBsol^2-BC^2==0;
solB=solve(eqB1,eqB2,xBsol,yBsol);
xBposizioni=eval(solB.xBsol);
yBposizioni=eval(solB.yBsol);
xB1=xBposizioni(1);
yB1=yBposizioni(1);
xB2=xBposizioni(2);
yB2=yBposizioni(2);
if (phi>=0 && phi<=pi)
if yB1>=0
xB=xB1;
yB=yB1;
else
xB=xB2;yB=yB2;
end
end
if (phi>pi && phi< 2*pi)
if yB1<0
xB=xB1; yB=yB1;
else
xB=xB2; yB=yB2;
end
end
rB=[xB yB 0];
figure(1)
plot([xA,xB],[yA,yB],'k-',[xB, xC],[yB,yC],'r-',[xA,xC],[yA,yC],'b-',[xB,xD],[yB,yD],'g-')
text(xA,yA,'A')
text(xB,yB,'B')
text(xC,yC,'C')
text(xD,yD,'D')
hold on
xlim([-0.5 0.5])
ylim([-0.5 0.5])
end

More Answers (0)

Categories

Find more on Argument Definitions in Help Center and File Exchange

Products


Release

R2016a

Community Treasure Hunt

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

Start Hunting!