Converting from symbolic to numerical data
Afficher commentaires plus anciens
I tried using double to convert from symbolic to numerical data but it is giving me the wrong answer.
syms A B C D theta(t) omega1(t) alpha1(t) t
assume([A B C D],"real")
Displacement analysis
syms beta(t) phi(t)
%for equilibrium, sum of displacement component on x and y axis must
%respectively be equal to zero
xdisp = A*cos(theta) + B*cos(beta) - C*cos(phi) - D == 0;
ydisp = A*sin(theta) + B*sin(beta) - C*sin(phi) == 0;
[angB,angD] = solve([xdisp,ydisp],[beta(t),phi(t)])
angB = simplify(angB);
angD = simplify(angD);
Velocity analysis
xvel = diff(xdisp,t);
yvel = diff(ydisp,t);
syms omega2(t) omega3(t)
xvel = subs(xvel,[diff(beta(t), t),diff(phi(t), t),diff(theta(t), t)],[omega2(t),omega3(t),omega1(t)]);
yvel = subs(yvel,[diff(beta(t), t),diff(phi(t), t),diff(theta(t), t)],[omega2(t),omega3(t),omega1(t)]);
[velB,velD] = solve([xvel,yvel],[omega2(t),omega3(t)]);
velB = simplify(velB);
velD = simplify(velD);
Acceleration analysis
xacc = diff(xvel,t);
yacc= diff(yvel,t);
syms alpha2(t) alpha3(t)
xacc = subs(xacc,[diff(omega1(t),t),diff(omega2(t),t),diff(omega3(t),t),diff(beta(t),t),diff(phi(t),t),diff(theta(t),t)],[alpha1(t),alpha2(t),alpha3(t),omega2(t),omega3(t),omega1(t)]);
yacc = subs(yacc,[diff(omega1(t),t),diff(omega2(t),t),diff(omega3(t),t),diff(beta(t),t),diff(phi(t),t),diff(theta(t),t)],[alpha1(t),alpha2(t),alpha3(t),omega2(t),omega3(t),omega1(t)]);
[accB,accD] = solve([xacc,yacc],[alpha2(t),alpha3(t)]);
accB = simplify(accB);
accD = simplify(accD);
Numerical values of the displacement, velocity and acceleration
angB = subs(angB,[A B C D theta(t) omega1(t) alpha1(t)],[300 360 360 600 30 10 -30]);
angD = subs(angD,[A B C D theta(t) omega1(t) alpha1(t)],[300 360 360 600 30 10 -30]);
angB = simplify(angB)
angD = simplify(angD)
angulardisp1 = double(angB)
If i use calculator to check th answer of angB it gives 35.12 which is correct but if i use double to convert the symbolic data to numerical data it gives 1.0024 which is wrong.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




