필터 지우기
필터 지우기

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 CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by