Changing varibles in a Matrix to Values

below is the problem I am trying to solve in MatLab. Everything works for computation of these matrix, but once I try to replace the variables with numbers I am receiving errors, or the answers are still in fraction form and pi isn't replaces by the number. Instead it still says cos(2*pi) for example. I would appreciate any help with this. Thanks for your time
syms r E G b h t A Ay Iz Iy alpha theta
LambdaQBt=[cos(alpha),sin(alpha),0;-sin(alpha),cos(alpha),0;0,0,1]
LambdaQB=transpose(LambdaQBt)
HQB=[1,0,0;0,1,0;-r*(1-cos(alpha)),r*sin(alpha),1]
HQBt=transpose(HQB)
TQB=(LambdaQBt*HQB)
fuq=[1/(E*A),0,0;0,1/(G*Ay),0;0,0,1/(E*Iz)]
TQBt=(HQBt*LambdaQB)
Product=(TQBt*fuq*TQB)
fBA=int(Product,alpha,0,theta)
r=3 E=200*10^9 G=77*10^9 b=.1 h=.0866 t=.01 Ay=.0049 Iz=(t*(b^3))/12 Iy=0 A=3*b*t
F=[10000;-5000;10000]
vB=fBA*F

3 commentaires

Sharyn Fallick
Sharyn Fallick le 2 Mar 2015
Also for this problem theta is equal to (4*pi)/9
Stephen23
Stephen23 le 16 Août 2018
Modifié(e) : Stephen23 le 16 Août 2018
If the symbolic expression does not contain any symbolic variables without values, then use double to convert a symbolic expression to a numeric value:
double(...)
Note that vB still depends on alpha, so this will not work for the above question, but it might be useful for others who find this thread.
To extend Stephen's answer, if the symbolic expression DOES contain any symbolic variables without values you can use the vpa function to approximate the numeric parts.
syms x
oneThird = sym(1)/3;
y = oneThird*x + x^2
vpa(y)

Connectez-vous pour commenter.

Réponses (2)

Tiasa Ghosh
Tiasa Ghosh le 16 Août 2018

0 votes

I guess the answer vB is still a symbolic expression is due to the fact that you have assigned numerical values to r,E,G,b and so on, after the fBA has already been evaluated as a symbolic expression. So in the last line when you compute fBa*F , the answer is obviously a symbolic expression.
Christopher Creutzig
Christopher Creutzig le 3 Déc 2018

0 votes

Assigning values to MATLAB variables does not affect symbolic expressions that have variables of the same name inside. Use the subs command instead. Or start with the concrete values instead of symbolic indeterminates.

Community Treasure Hunt

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

Start Hunting!

Translated by