フィルターのクリア

How to get Numerical value from a Symbol?

44 ビュー (過去 30 日間)
zongquan
zongquan 2012 年 1 月 29 日
コメント済み: Torsten 2023 年 4 月 19 日
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
Vani Madhavi Tukkapuram 2023 年 4 月 19 日
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 件のコメント
Vani Madhavi Tukkapuram
Vani Madhavi Tukkapuram 2023 年 4 月 19 日
get the T value
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 Center および File ExchangeAssumptions についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by