Borrar filtros
Borrar filtros

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

7 visualizaciones (últimos 30 días)
Jonas Freiheit
Jonas Freiheit el 6 de Ag. de 2021
Respondida: Zuber Khan el 18 de Jul. de 2024 a las 6:54
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

Respuestas (1)

Zuber Khan
Zuber Khan el 18 de Jul. de 2024 a las 6:54
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

Categorías

Más información sobre Thermodynamics and Heat Transfer en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by