i was trying to solve a simple system of equations, when the program gives me this error:
Error using evalinUndefined 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:
clearAC=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;endendif (phi>pi && phi< 2*pi) if yB1<0 xB=xB1; yB=yB1; else xB=xB2; yB=yB2; endendrB=[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 onxlim([-0.5 0.5])ylim([-0.5 0.5])end
Best Answer