The variables always appear as (1x400 sym) in workspace

조회 수: 1 (최근 30일)
Hasan Al Tarify
Hasan Al Tarify 2021년 12월 14일
댓글: Hasan Al Tarify 2021년 12월 15일
Hello,
I have a problem with the values of cv2 that are not substituted with the values of (xd), hence no substitution in cv3. It says cv2 = 1x400 sym in workspace, I don't know where i made a mistake. Please help me, i would appriciate it.
clc
clear all
syms x T xd
T = linspace(12,1000,400);
kb = 1.38*10^-23;
xd = T/2240;
h = 6.64*10^-34;
v = 18000;
p = 6.*kb.^4*T.^3./(pi.^2*h.^3*v.^3);
%y = x^4*exp(x)/(exp(x)-1)^2;
%cv = p.*24.*(x.^3.*log(exp(x)-1)./6 + polylog(4,exp(x)) - x.*polylog(3,exp(x)) + x.^2.*polylog(2,exp(x))/2) - p.*x.^4./(exp(x)-1) - p.*x.^4;
cv2 = p.*24.*(xd.^3.*log(exp(xd)-1)./6 + polylog(4,exp(xd)) - x.*polylog(3,exp(xd)) + x.^2.*polylog(2,exp(xd))/2) - p.*x.^4./(exp(xd)-1) - p.*x.^4;
Li = polylog(4,exp(0));
cv3 = cv2 - Li;
  댓글 수: 2
Muhammad Usman
Muhammad Usman 2021년 12월 14일
The error you were getting due to:
syms x T xd
But you defined T as linscpace and xd depends on T and they were both 1x400 double array, but x was defined as symbol so that makes cv2 and cv3 1x400 symbol
Hasan Al Tarify
Hasan Al Tarify 2021년 12월 14일
Oh I see, would you give a suggestion to make it work? The fucntion must have the variable X and will be substituted with xd. Thank you

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2021년 12월 14일
clc
clear all
syms x T xd
Tvals = linspace(12,1000,400);
kb = 1.38*10^-23;
xd = T/2240;
h = 6.64*10^-34;
v = 18000;
p = 6.*kb.^4*T.^3./(pi.^2*h.^3*v.^3);
%y = x^4*exp(x)/(exp(x)-1)^2;
%cv = p.*24.*(x.^3.*log(exp(x)-1)./6 + polylog(4,exp(x)) - x.*polylog(3,exp(x)) + x.^2.*polylog(2,exp(x))/2) - p.*x.^4./(exp(x)-1) - p.*x.^4;
cv2 = p.*24.*(xd.^3.*log(exp(xd)-1)./6 + polylog(4,exp(xd)) - x.*polylog(3,exp(xd)) + x.^2.*polylog(2,exp(xd))/2) - p.*x.^4./(exp(xd)-1) - p.*x.^4;
Li = polylog(4,exp(0));
cv3(x,T) = cv2 - Li;
result = cv3(x,Tvals);
rv = vpa(result, 8);
rv(1:2).'
ans = 
result would be a 1 x 400 expression involving the variable x
  댓글 수: 3
Walter Roberson
Walter Roberson 2021년 12월 15일
What size of output are you expecting? You have a function that has a different formula at each time point; it appears that it can be approximated as a complex quartic at each time.
If you create a column vector of x values, and subs() that in for x in result then you would get a 2D array with one row for each different x value, and with 400 columns (one for each time.)
Hasan Al Tarify
Hasan Al Tarify 2021년 12월 15일
Oh I see. I just figured out the problem was in the function so I made an integration and exported the values, and it worked out. Thank you for your help.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by