Unable to convert expression into double array.

29 views (last 30 days)
I have a 20 equations to solve i have already the symbolic funtioncs of M , E ,Izz and when i try to solve it appears in the command window( Unable to convert expression into double array.) This is the code
syms c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 M1(x) M2(x) M3(x) M4(x) M5(x) M6(x) M7(x) M8(x) M9(x) M10(x) T(x) E2(x) E3(x) E4(x) Izz3(x) Izz2(x) Izz4(x)
delta1 = int(int(M1/(E1*Izz1),x),x) + c1*x + c2;
delta2 = int(int(M2/(E2*Izz2),x),x) + c3*x + c4;
delta3 = int(int(M3/(E3*Izz3),x),x) + c5*x + c6;
delta4 = int(int(M4/(E4*Izz4),x),x) + c7*x + c8;
delta5 = int(int(M5/(E5*Izz5),x),x) + c9*x + c10;
delta6 = int(int(M6/(E6*Izz6),x),x) + c11*x + c12;
delta7 = int(int(M7/(E7*Izz7),x),x) + c13*x + c14;
delta8 = int(int(M8/(E8*Izz8),x),x) + c15*x + c16;
delta9 = int(int(M9/(E9*Izz9),x),x) + c17*x + c18;
delta10 = int(int(M10/(E10*Izz10),x),x) + c19*x + c20;
s1 = int(M1/(E1*Izz1),x) + c1;
s2 = int(M2/(E2*Izz2),x) + c3;
s3 = int(M3/(E3*Izz3),x) + c5;
s4 = int(M4/(E4*Izz4),x) + c7;
s5 = int(M5/(E5*Izz5),x) + c9;
s6 = int(M6/(E6*Izz6),x) + c11;
s7 = int(M7/(E7*Izz7),x) + c13;
s8 = int(M8/(E8*Izz8),x) + c15;
s9 = int(M9/(E9*Izz9),x) + c17;
s10 = int(M10/(E10*Izz10),x) + c19;
%For Turbine
eq1 = subs(delta1,x,K1) == subs(delta2,x,K1); eq2 = subs(s1,x,K1) == subs(s2,x,K1);
eq3 = subs(delta2,x,K2) == subs(delta3,x,K2); eq4 = subs(s2,x,K2) == subs(s3,x,K2);
eq5 = subs(delta3,x,K3) == subs(delta4,x,K3); eq6 = subs(s3,x,K3) == subs(s4,x,K3);
eq7 = subs(delta4,x,K4) == subs(delta5,x,K4); eq8 = subs(s4,x,K4) == subs(s5,x,K4);
eq9 = subs(delta5,x,K5) == subs(delta6,x,K5); eq10 = subs(s5,x,K5) == subs(s6,x,K5);
eq11 = subs(delta6,x,K6) == 0; eq12 = subs(s6,x,K6) == 0;
%For Generator
eq13 = subs(delta7,x,K7) == subs(delta8,x,K7); eq14 = subs(s7,x,K7) == subs(s8,x,K7);
eq15 = subs(delta8,x,K8) == subs(delta9,x,K8); eq16 = subs(s8,x,K8) == subs(s9,x,K8);
eq17 = subs(delta9,x,K9) == subs(delta10,x,K9); eq18 = subs(s9,x,K9) == subs(s10,x,K9);
eq19 = subs(delta7,x,K6) == 0; eq20 = subs(s7,x,K6) == 0;
sol1 = solve(eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11,eq12,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12);
sol2 = solve(eq13,eq14,eq15,eq16,eq17,eq18,eq19,eq20,c13,c14,c15,c16,c17,c18,c19,c20);
c1 = double(c1); c2 = double(sol1.c2); c3 = double(sol1.c3); c4 = double(sol1.c4); c5 = double(sol1.c5);
c6 = double(sol1.c6); c7 = double(sol1.c7); c8 = double(sol1.c8); c9 = double(sol1.c9); c10 = double(sol1.c10);
c11 = double(sol1.c11); c12 = double(sol1.c12); c13 = double(sol2.c13); c14 = double(sol2.c14); c15 = double(sol2.c15);
c16 = double(sol2.c16); c17 = double(sol2.c17); c18 = double(sol2.c18); c19 = double(sol2.c19); c20 = double(sol2.c20);
delta1 = int(int(M1/(E1*Izz1),x),x) + c1*x + c2
delta2 = int(int(M2/(E2*Izz2),x),x) + c3*x + c4;
delta3 = int(int(M3/(E3*Izz3),x),x) + c5*x + c6;
delta4 = int(int(M4/(E4*Izz4),x),x) + c7*x + c8;
delta5 = int(int(M5/(E5*Izz5),x),x) + c9*x + c10;
delta6 = int(int(M6/(E6*Izz6),x),x) + c11*x + c12;
delta7 = int(int(M7/(E7*Izz7),x),x) + c13*x + c14;
delta8 = int(int(M8/(E8*Izz8),x),x) + c15*x + c16;
delta9 = int(int(M9/(E9*Izz9),x),x) + c17*x + c18;
delta10 = int(int(M10/(E10*Izz10),x),x) + c19*x + c20;
what am i doing wrong?
  2 Comments
Dimitrios Adam
Dimitrios Adam on 8 Dec 2019
Hello,
They dont have a numeric value and i dont know why when i type c1 it shows nothing
How can i fix this?

Sign in to comment.

Answers (1)

Jesus Sanchez
Jesus Sanchez on 8 Dec 2019
Your problem is that you did not assign numerical values to your sym variables. Therefore, when you do double(sym_variable), matlab does not find anything that it can convert and throws an error.
To check this, execute this code section by section. Its the same as your code. You should see that when executing double(c1) for example, there is an error:
Error using symengine
Unable to convert expression into double array.
Error in sym/double (line 661)
Xstr = mupadmex('symobj::double', S.s, 0);
I could not execute the code, as M1 and E1 are not provided. Maybe the error jumps before the lines that I marked. If so, do the same comprobation, check if the symbolical variable has numerical value.
syms c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 M1(x) M2(x) M3(x) M4(x) M5(x) M6(x) M7(x) M8(x) M9(x) M10(x) T(x) E2(x) E3(x) E4(x) Izz3(x) Izz2(x) Izz4(x)
delta1 = int(int(M1/(E1*Izz1),x),x) + c1*x + c2;
delta2 = int(int(M2/(E2*Izz2),x),x) + c3*x + c4;
delta3 = int(int(M3/(E3*Izz3),x),x) + c5*x + c6;
delta4 = int(int(M4/(E4*Izz4),x),x) + c7*x + c8;
delta5 = int(int(M5/(E5*Izz5),x),x) + c9*x + c10;
delta6 = int(int(M6/(E6*Izz6),x),x) + c11*x + c12;
delta7 = int(int(M7/(E7*Izz7),x),x) + c13*x + c14;
delta8 = int(int(M8/(E8*Izz8),x),x) + c15*x + c16;
delta9 = int(int(M9/(E9*Izz9),x),x) + c17*x + c18;
delta10 = int(int(M10/(E10*Izz10),x),x) + c19*x + c20;
s1 = int(M1/(E1*Izz1),x) + c1;
s2 = int(M2/(E2*Izz2),x) + c3;
s3 = int(M3/(E3*Izz3),x) + c5;
s4 = int(M4/(E4*Izz4),x) + c7;
s5 = int(M5/(E5*Izz5),x) + c9;
s6 = int(M6/(E6*Izz6),x) + c11;
s7 = int(M7/(E7*Izz7),x) + c13;
s8 = int(M8/(E8*Izz8),x) + c15;
s9 = int(M9/(E9*Izz9),x) + c17;
s10 = int(M10/(E10*Izz10),x) + c19;
%% For Turbine
eq1 = subs(delta1,x,K1) == subs(delta2,x,K1); eq2 = subs(s1,x,K1) == subs(s2,x,K1);
eq3 = subs(delta2,x,K2) == subs(delta3,x,K2); eq4 = subs(s2,x,K2) == subs(s3,x,K2);
eq5 = subs(delta3,x,K3) == subs(delta4,x,K3); eq6 = subs(s3,x,K3) == subs(s4,x,K3);
eq7 = subs(delta4,x,K4) == subs(delta5,x,K4); eq8 = subs(s4,x,K4) == subs(s5,x,K4);
eq9 = subs(delta5,x,K5) == subs(delta6,x,K5); eq10 = subs(s5,x,K5) == subs(s6,x,K5);
eq11 = subs(delta6,x,K6) == 0; eq12 = subs(s6,x,K6) == 0;
%% For Generator
eq13 = subs(delta7,x,K7) == subs(delta8,x,K7); eq14 = subs(s7,x,K7) == subs(s8,x,K7);
eq15 = subs(delta8,x,K8) == subs(delta9,x,K8); eq16 = subs(s8,x,K8) == subs(s9,x,K8);
eq17 = subs(delta9,x,K9) == subs(delta10,x,K9); eq18 = subs(s9,x,K9) == subs(s10,x,K9);
eq19 = subs(delta7,x,K6) == 0; eq20 = subs(s7,x,K6) == 0;
sol1 = solve(eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11,eq12,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12);
sol2 = solve(eq13,eq14,eq15,eq16,eq17,eq18,eq19,eq20,c13,c14,c15,c16,c17,c18,c19,c20);
%% PROBLEMATIC section
% Check if double(sym_variable) of all the variables here present gives this error. There should be one without numerical value
c1 = double(c1); c2 = double(sol1.c2); c3 = double(sol1.c3); c4 = double(sol1.c4); c5 = double(sol1.c5);
c6 = double(sol1.c6); c7 = double(sol1.c7); c8 = double(sol1.c8); c9 = double(sol1.c9); c10 = double(sol1.c10);
c11 = double(sol1.c11); c12 = double(sol1.c12); c13 = double(sol2.c13); c14 = double(sol2.c14); c15 = double(sol2.c15);
c16 = double(sol2.c16); c17 = double(sol2.c17); c18 = double(sol2.c18); c19 = double(sol2.c19); c20 = double(sol2.c20);
%% Continues
delta1 = int(int(M1/(E1*Izz1),x),x) + c1*x + c2
delta2 = int(int(M2/(E2*Izz2),x),x) + c3*x + c4;
delta3 = int(int(M3/(E3*Izz3),x),x) + c5*x + c6;
delta4 = int(int(M4/(E4*Izz4),x),x) + c7*x + c8;
delta5 = int(int(M5/(E5*Izz5),x),x) + c9*x + c10;
delta6 = int(int(M6/(E6*Izz6),x),x) + c11*x + c12;
delta7 = int(int(M7/(E7*Izz7),x),x) + c13*x + c14;
delta8 = int(int(M8/(E8*Izz8),x),x) + c15*x + c16;
delta9 = int(int(M9/(E9*Izz9),x),x) + c17*x + c18;
delta10 = int(int(M10/(E10*Izz10),x),x) + c19*x + c20;
  2 Comments
Dimitrios Adam
Dimitrios Adam on 9 Dec 2019
I execute this and the answer is this
Error using symengine
Unable to convert expression into double array.
Error in sym/double (line 672)
Xstr = mupadmex('symobj::double', S.s, 0);
I will give you the code for the M1 end E and Izz
D1 = 0.23;
p = 7860;
D5=0.27;
D6=0.22;
g= 9.8;
D2 = 1;
l1 = 1.6;
L5 = 2.8 ;
l2 = L5/2 ;
K1 = l1;
L2 = 2.2;
K2 = K1 + l2;
l5 =2.3;
L6 = 1 ;
l6= L2/2;
l3 =2*(L5/2 - L6);
K3 = K2 + l3;
l4 = L5/2 - l3;
K4 = K3 + l4;
K5 = K4 + l5;
L7 = L2 - l6;
K6 = K5 + l6;
l7 = L7;
K7 = K6 + l7;
D7=0.29;
D3 = 0.35 ;
D4 = 0.6;
L9 = 1.6 ;
L8= 3*(D3+D4) - L9;
l8=L8;
l9= 2*L9 ;
l10 = L8;
b= (D5-D2)/L5;
L1 = 2*l8+l9
c = D2 -((D5-D2)/L5)*l1;
e = p*g*pi/4;
K8=K7+l8;
K9=K8+l9;
K10=K9+l10
K2+l3/2;
syms x
q2 = ((((D5-D2)/L5)*x +D2 -((D5-D2)/L5)*l1)^2)*p*g*pi/4;
I2 = int(q2,K1,K2);
I1 = pi*p*g*D1^2*l1/4;
I5 = pi*p*g*D5^2*l5/4;
I6= pi*p*g*D6^2*l6/4;
I3 = 5/9*int(q2,K2,K3);
I4 = int(q2,K3,K4) ;
Fy12 = I1 + I2 +I3 +I4 +I5 +I6;
R1 = ((I1*(K5 - K1/2) + I2*(K5 -K1 - l2/2) + I3*(K5 - K1 -l2 -l3/2) + I4*(K5 -l1 - l2 -l3 -l4/2) + I5*l5/2 -I6*l6/2)/K5);
R2 = (Fy12 -R1);
I7 = pi*p*g*D7^2*l7/4;
I8 = pi*p*g*D3^2*l8/4;
I9 = pi*p*g*D4^2*l9/4;
I10= pi*p*g*D3^2*l10/4;
Sfy = I7 + I8 + I9 + I10;
R3 = ((I7*(l10+l9+l8+l7/2) + I8*(l9 +l10 + l8/2) + I9*(l10 + l9/2) + I10*(l10/2))/(l8+l9+l10));
R4 = (Sfy - R3);
syms x
II1=p*g*pi*D1^2/4*x; II2=int(q2,K1,x); II3=5/9*int(q2,K2,x); II4= int(q2,K3,x);II5=p*g*pi*D5^2/4*(x-K4);II6=p*g*pi*D6^2/4*(x-K5);II7=p*g*pi*D7^2/4*(x-K6);II8=pi*p*g*D3^2*(x-K7)/4;II9=pi*p*g*D4^2*(x-K8)/4;II10=pi*p*g*D3^2*(x-K9)/4;
V1 = R1 - II1;
V2 = R1 -I1-II2;
V3= R1-I1-I2-II3;
V4= R1-I1-I2-I3-II4;
V5= R1-I1-I2-I3-I4-II5;
V6=R1+R2-I1-I2-I3-I4-I5-II6;
V7=-II7;
V8=R3-II8-I7;
V9=R3-I8-I7-II9;
V10=R3-I8-I7-I9-II10;
M1=R1*x-p*g*pi*D1^2/4*x*x/2;
M2=R1*x-I1*(x-l1/2)-(131*pi*(5*x - 8)*(133225*x^2 - 1959320*x + 8673856))/200000*(x-K1)/2;
M3=R1*x-I1*(x-l1/2)-I2*(x-K1-l2/2)-5/9*(131*pi*(x - 3)*(133225*x^2 - 1772805*x + 6490353))/40000*(x-K2)/2;
M4= R1*x-I1*(x-l1/2)-I2*(x-K1-l2/2)-I3*(x-K2-l3/2)-131*pi*(5*x - 19)*(133225*x^2 - 1666225*x + 5477113)/200000*(x-K3)/2;
M5=R1*x-I1*(x-l1/2)-I2*(x-K1-l2/2)-I3*(x-K2-l3/2)-I4*(x-K3-l4/2)-p*g*pi*D5^2/4*(x-K4)*(x-K4)/2
M6=R1*x-I1*(x-l1/2)-I2*(x-K1-l2/2)-I3*(x-K2-l3/2)-I4*(x-K3-l4/2)-I5*(x-K4-l5/2)-p*g*pi*D6^2/4*(x-K5)*(x-K5)/2+R2*(x-K5);
M7=-p*g*pi*D7^2/4*(x-K6)*(x-K6)/2;
M8=R3*(x-K7)-I7*(x-K6-l7/2)-pi*p*g*D3^2*(x-K7)/4*(x-K7)/2;
M9=R3*(x-K7)-I7*(x-K6-l7/2)-I8*(x-K7-l8/2)-pi*p*g*D4^2*(x-K8)/4*(x-K8)/2;
M10=R3*(x-K7)-I7*(x-K6-l7/2)-I8*(x-K7-l8/2)-I9*(x-K8-l9/2)-pi*p*g*D3^2*(x-K9)/4*(x-K9)/2;
syms T(x)
T=460/L5*x +40 -460*l1/L5;
E1=207.08*10^9;
E2= (-0.0011*T+ 2.1148)*10^11;
E3= (-0.0011*T + 2.1148)*10^11;
E4= (-0.0011*T + 2.1148)*10^11;
E5=207.08*10^9;
E6=207.08*10^9;
E7=207.08*10^9;
E8=207.08*10^9;
E9=207.08*10^9;
E10=207.08*10^9;
syms d1(x) d2(x) d3(x)
d1 = (b*x+c);
d2 = (b*x+c);
d3 = (b*x+c);
Izz1 = pi*D1^4/64;
Izz2 = pi*d1^4/64;
Izz3 = 65/81*pi*d2^4/64;
Izz4 = pi*d3^4/64;
Izz5 = pi*D5^4/64;
Izz6 = pi*D5^4/64;
Izz7 = pi*D7^4/64;
Izz8 = pi*D3^4/64;
Izz9 = pi*D4^4/64;
Izz10 = pi*D3^4/64;

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!