Reference to non-existent field 'aD42'? Please help.
2 次查看(过去 30 天)
显示 更早的评论
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);
2 个评论
Walter Roberson
2012-12-8
Put a breakpoint after the solve() and see what fields were returned for solaD
Note: you should not eval() a symbolic variable. symbolic variables are not MATLAB expressions, they are just very similar to MATLAB expressions. You should subs() or double() the symbolic variable.
采纳的回答
Matt Fig
2012-12-8
编辑:Matt Fig
2012-12-8
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.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 MuPAD 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!