MATLAB: Reference to non-existent field ‘aD42’? Please help.

MATLABmechanismnon-existent fieldreference error

I am trying to calculate the acceleration of a mechanism and I am stuck with this error:
Reference to non-existent field 'aD42'.
Error in xyz12 (line 285) aDpds = eval(solaD.aD42);
here are the code lines that describe the acceleration and the aD42 variable:
aE=[0 0 0];
ep5z = sym('ep5z','real');
ep5 = [ 0 0 ep5z ];
aD42=sym('aD42','real');
aD4D2 = [ aD42*cos(phi4) aD42*sin(phi4) 0 ];
aD5=aE+cross(ep5,rD-rE)- dot(Omega5,Omega5)*(rD-rE);
aD4 = aD5;
aD4D2cor = 2*cross(omega2,VD42);
eqaD = aD4 - ( aB2 + aD4D2 + aD4D2cor );
eqaDx = eqaD(1); eqaDy = eqaD(2);
solaD = solve(eqaDx,eqaDy);
ep5zs = eval(solaD.ep5z);
aDpds = eval(solaD.aD42);
Ep5 = [0 0 ep5zs];
AD42 = aDpds*[cos(phi4) sin(phi4) 0];
AD5=aE+cross(Ep5,rD-rE)-...
dot(Omega5,Omega5)*(rD-rE);

Best Answer

Use this line:
solaD = solve(eqaDx,eqaDy,ep5z,aD42)
Instead of the one you use for solaD. The problem is you have three unknowns and two equations, so SOLVE chose to leave aD42 as the independent variable in the solutions.
Also, when you call FPRINTF with a symbolic variable you need to convert in with CHAR first.
fprintf('aD4D2cor = [%g, %g, %d] (m/sˆ2)\n', char(aD4D2cor))
and so for the rest.