How to get Numerical value from a Symbol?

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

 Risposta accettata

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

Più risposte (1)

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 Commenti

get the T value
Your expression is too difficult to be solved for T explicitly.
Give values to the other parameters and use "vpasolve".

Accedi per commentare.

Categorie

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by