Blank screen when plotting a graph and how to partial differentiate?

조회 수: 9 (최근 30일)
Jonas Freiheit
Jonas Freiheit 2021년 8월 6일
답변: Zuber Khan 2024년 7월 18일
p_RK = @(v,T) (R*T*(1/(v-b) - a/(R*T^1.5*v*(v+b)))) % The redlich kwong equation
How can I partiall differentiate this function with respect to v?
Also plotting this seems to work for the pressure coefficient
alphav = @(v) ((R/(v-b)+a/(2*T^1.5*v*(v+b)))/p_RK_T(v))
% plot alpha_v over the required range
figure
fplot(alphav, [v1 v2])
hold on
but when I try plotting this I get a blank screen:
diffp_volume=@(v) (((-R*T)/(v^2-b))+(a*(2*v+b)/(v^2*T^1/2*(v+b)^2)))
kt = @(v) -1/diffp_volume*v
% plot alpha_p over the required range
figure
fplot(kt, [v1 v2])
hold on
What can I do? Also I can send the whole code if this doesnt make sense
Thanks
As a note this is about thermodynamics on plotting the coefficient of thermal expansion

답변 (1개)

Zuber Khan
Zuber Khan 2024년 7월 18일
Hi,
As far as your first question is concerned, you can partially differentiate the given function with respect to 'v' using symbolic differentiation in MATLAB. Here is a code snippet for your reference.
syms v T R b a
p_RK = R*T*(1/(v-b) - a/(R*T^1.5*v*(v+b)));
result = diff(p_RK, v);
disp(result);
You can refer to the following documentation for more information:
For the second question, I did not understand the purpose of defining variable 'kt' since these operations can be included in the 'diffp_volume' function handle itself. I tried keeping only one function handle in the script, and the "fplot" function work as expected. You can refer to the following code snippet for reference. Since I am not aware of other variables, I substituted random values for the time being.
v1 = 1;
v2 = 100;
R=0.5;
b=1;
a=2;
T=0.3;
diffp_volume=@(v) -1/(((-R*T)/(v^2-b))+(a*(2*v+b)/(v^2*T^1/2*(v+b)^2)))*v;
% plot alpha_p over the required range
figure
fplot(diffp_volume, [v1 v2])
hold on
I hope this resolves your issue.
Regards,
Zuber

카테고리

Help CenterFile Exchange에서 Thermodynamics and Heat Transfer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by