Blank screen when plotting a graph and how to partial differentiate?
1 view (last 30 days)
Show older comments
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
Answers (1)
Zuber Khan
on 18 Jul 2024
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
0 Comments
See Also
Categories
Find more on Thermodynamics and Heat Transfer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!