help, pls how can i convert from syms to double

clc
clear all
syms s
Kw= 0.05;Ka=0.01;
T=0.1; R=500;
f=50; L=2500*10^-6;
X=2*pi*f*L;
d0_1=-0.019; d0_2=0.019; dw1=0.5; dw2=-0.5; dV1=0; dV2=0;
dPavg1=-10; dPavg2=10; dQavg1=0; dQavg2=0;
M=4*X + X^3/R^2;
t=(0:0.2:2)
V1eq=23;
V2eq=23;
O1eq=0.019;
O2eq=-0.019;
a1=(2*X*V1eq/R + 2*V2eq*sin(O1eq - O2eq) + X*V2eq/R*cos(O1eq - O2eq))/4*X + X^3/R^2;
b1=(2*V1eq*sin(O1eq - O2eq) + (X/R)*V1eq*cos(O1eq - O2eq))/M;
c1=(2*V1eq*V2eq*cos(O1eq - O2eq) - (X/R)*V1eq*V2eq*sin(O1eq - O2eq))/M;
d1=-c1;
a2=(2*V2eq*sin(O2eq - O1eq) + (X/R)*V2eq*cos(O2eq - O1eq))/M;
b2=(2*V2eq*X/R + 2*V1eq*sin(O2eq - O1eq) + V1eq*(X/R)*cos(O2eq -O1eq))/M;
c2=(-2*V1eq*V2eq*cos(O2eq - O1eq) + (X/R)*V1eq*V2eq*sin(O2eq - O1eq))/M;
d2= -c2;
a3=(2*(X^2/R^2 + 2)*V1eq - 2*V2eq*cos(O1eq - O2eq) + X/R*V2eq*sin(O1eq - O2eq))/M;
b3=(-2*V1eq*cos(O1eq - O2eq) + X/R*V1eq*sin(O1eq - O2eq))/M;
c3=(2*V1eq*V2eq*sin(O1eq - O2eq) + X/R*V1eq*V2eq*cos(O1eq - O2eq))/M;
d3= -c3;
a4= (-2*V2eq*cos(O2eq - O1eq) + (X/R)*V2eq*sin(O2eq - O1eq));
b4=(2*(2+X^2/R^2)*V2eq - 2*V1eq*cos(O2eq - O1eq) + X/R * V1eq*sin(O2eq - O1eq))/M;
c4=(-2*V1eq*V2eq*sin(O2eq - O1eq) - X/R*V1eq*V2eq*cos(O2eq - O1eq));
d4=-c4;
X1=[d0_1; d0_2; dw1; dw2; dV1; dV2; dPavg1; dPavg2; dQavg1; dQavg2];
A1=[0 1 0 0 0 0 0 0 0 0;
0 0 0 1 0 0 0 0 0 0;
(-Kw*c1)/T (-Kw*d1)/T -1/T 0 (-Kw*a1)/T (-Kw*b1)/T 0 0 0 0;
(-Kw*c2)/T (-Kw*d2)/T 0 -1/T (-Kw*a2)/T (-Kw*b2)/T 0 0 0 0;
(-Ka*c3)/T (-Ka*d3/T) 0 0 (1+Ka*a3)/T (-Ka*b3/T) 0 0 0 0;
(-Ka*c4)/T (-Ka*d4)/T 0 0 (-Ka*a4)/T -(1+Ka*b4)/T 0 0 0 0;
c1/T d1/T 0 0 a1/T b1/T -1/T 0 0 0;
c2/T d2/T 0 0 a2/T b2/T 0 -1/T 0 0;
c3/T d3/T 0 0 a3/T b3/T 0 0 -1/T 0;
c4/T d4/T 0 0 a4/T b4/T 0 0 0 -1/T]
sX1=A1*X1
plot(t,dPavg1)

3 Comments

You define the symbol s but you never use it, so there is are no symbolic expressions to convert to double.
You are defining a symbolic variable s, but I cannot see you using it anywhere?
Note that your dPavg1 is just the scalar value -10 so you would have trouble seeing your plot.

Sign in to comment.

 Accepted Answer

It's true that you haven't used s but the answer to your question is as easy as this:
>> syms s
>> number=s+s-3/4 %The result will be 3/4 as symbolic
>> number2=double(number) %Now the result is 0.7500
So, the function is double(var)
Hope it's useful. Regards

1 Comment

I wrote syms x instead of syms s. Sorry about that. It's already been corrected

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!