How to get Numerical value from a Symbol?

44 次查看(过去 30 天)
Hi, everyone,
I was working on extracting the numerical value of a symbol, however, it does't work for me.
x=2*y+5*y^3+3*y^5 and I have a series values of 'x'. What I want is to get the numerical values of 'y' which contains only pure real values.
When I wrote "solve('x=2*y+5*y^3+3*y^5','y')", it gave me 5 numerical answers on screen. However, it showed "5*1 syms" in the Workspace. Moreover, when I put the "solve" in the 'for' loop, it only showed 1*1 sym.
I am wondering who could help me this. Your suggestion is highly appreciated!
Thank you

采纳的回答

Walter Roberson
Walter Roberson 2012-1-29
Use double() to convert a symbolic number to a double precision value.

更多回答(1 个)

Vani Madhavi Tukkapuram
D = 1000;
Co = 2000;
Cs = 200;
Cp = 100;
Ch = 0.20;
Cd = 0.15;
R = 20;
t1 = 5;
syms D Co Cs Cp Ch Cd R t1 T
%theta(t) = 1 / (1 + R - t);
%I1(t) = L - D * t;
%I2(t) = D(1 + R - t) * log((1 + R - t1)/(1 + R - T));
L = D * (t1 + ((1 + R - t1) * log((1 + R - t1)/(1 + R - T))));
OC = Co;
HC_1 = (L * t1)-((D * t1^2)/2) + D *(1 + R);
HC_2 = (-T + t1);
HC_3 = (1 + R)/2;
HC_4 = (3/2) * (t1^2/(1+R));
HC_5 = log((1 + R - t1)/(1 + R - T));
HC_6 = (T + 3*t1)/2;
HC_7 = t1*log(1 + R-t1)-T*log(1+R-T);
HC = Ch*(HC_1*((HC_2-HC_3-HC_4)*(HC_5+HC_6+HC_7)));
DC_1 = D*Cd;
DC_2 = (T-t1);
DC_3 = (1+R-t1)*log((1 + R - t1)/(1 + R - T));
DC = DC_1*(-DC_2+DC_3);
PC_1 = D*Cp;
PC_2 = t1;
PC_3 = (1+R-t1)*log((1 + R - t1)/(1 + R - T));
PC = PC_1 * (PC_2 + PC_3);
SRC = D*Cs*T;
TP = (SRC - OC - HC - DC - PC)./T;
f = TP==0;
diff(f,T);
disp('---------------------------------');
  2 个评论
Torsten
Torsten 2023-4-19
Your expression is too difficult to be solved for T explicitly.
Give values to the other parameters and use "vpasolve".

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by