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

1 view (last 30 days)
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 Comments
Muhammad Usman
Muhammad Usman on 14 Dec 2021
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 on 14 Dec 2021
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

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 14 Dec 2021
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 Comments
Walter Roberson
Walter Roberson on 15 Dec 2021
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 on 15 Dec 2021
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!