Interpolation and integration 501
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52
53 function out=plot vdw(T,a,b,Vmin,Vmax,Pmin,Pmax)
54 %Plot vdw EOS between Vmin,Vmax and Pmin,Pmax. returns h to …
64 ylabel(‘$P$ (MPa)’,‘FontSize’,14)
65 top = strcat(‘vdw Equation for $T = $’,num2str(T),‘K’);
66 title(top,‘FontSize’,14)
67 out = h;
68
77 function out = find V(P,V,T,a,b)
78 %executes Newton’s method to find a value of V in L/mol when …
the vdw
79 %equation of state is written as f(V) = 0 with the pressure in …
MPa, the
90 fprintf(‘Failed to compute volume for Vinit = %6.4f …
‘,Vinit)
91 fprintf(‘P = %6.4f and T = %6.2f’,P,T)
92 fVeval = 0; %stop the loop
93 V = 0; %write nonsense for the answer