problem with the symbolic calculation

Hello! i have a problem: I have a peace of code:
Q1=30;
Q1rad=(pi/180)*Q1;
S1= sym('sin(Q1rad)');
double(S1)
and it doesn.t work because I translate variable to the 'sin(...)' how to make it works? what is the way to calculate expressions with "sin(Q1rad)" and in the end substitute the Q1rad, and calculate the final value of the expression?
best regards! Dmytro.

 Accepted Answer

I translate variable to the 'sin(...)' , what doesthat mean?
If you want double(S1), just write:
sin(Q1rad)

5 Comments

for example, why I can not compute double(C) here?
syms A B C S1 S2 S3;
A=[S1 S2 1;2 3 S2; 3 S1 S3];
B=[S3 S1 1;3 2 S1; 2 S3 S2];
C=A*B;
Q1=30;Q2=20;Q3=10;
Q1rad=(pi/180)*Q1;
Q2rad=(pi/180)*Q2;
Q3rad=(pi/180)*Q3;
S1=sin(Q1rad)
S2=sin(Q2rad)
S3=sin(Q3rad)
double(C)
%Do not put the cart before the horse
syms A B C S1 S2 S3;
Q1=30;Q2=20;Q3=10;
Q1rad=(pi/180)*Q1;
Q2rad=(pi/180)*Q2;
Q3rad=(pi/180)*Q3;
S1=sin(Q1rad)
S2=sin(Q2rad)
S3=sin(Q3rad)
A=[S1 S2 1;2 3 S2; 3 S1 S3];
B=[S3 S1 1;3 2 S1; 2 S3 S2];
C=A*B;
double(C)
:DD sorry maybe my questions are a little stupid, but why I can not compute here double(S1) ? or I should change my approach?
Q1=30;
Q1rad=(pi/180)*Q1;
S1= sym('sin(Q1rad)');
double(S1)
Q1=30;
Q1rad=(pi/180)*Q1;
S1= sym('sin(Q1rad)')
double(subs(S1))
YES) Thank you!

Sign in to comment.

More Answers (1)

q = [30;20;10];
S = sind(q);
A = [S(1) S(2) 1;2 3 S(2);3 S(1) S(3)];
B=[S(3) S(1) 1;3 2 S(1); 2 S(3) S(2)];
C = A*B;

Asked:

Dk
on 6 Nov 2013

Commented:

Dk
on 6 Nov 2013

Community Treasure Hunt

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

Start Hunting!