Using Matlab Reduced quantities are often used in thermodynamics: reduced temper
ID: 3160970 • Letter: U
Question
Using Matlab Reduced quantities are often used in thermodynamics: reduced temperature Tr= T/Tc, reduced pressure Pr = P/Pc, and reduced volume Vr = V/Vc, where Tc, Pc, and Vc are the corresponding quantities at the critical point. The ideal gas law can be expressed in terms of the reduced quantities as Pr Vr = 8/3 Tr a) Write a function file that accepts an array of Vr and returns the corresponding arrays of Pr for Tr =1 and 2. That is, the file calculates Pr 1 and Pr 2 that are the arrays for Tr =1 and Tr =2, respectively. Note that the file requires element-by-element operations (how do we do the operations?). b) Write a script file that defines Vr = (0.5, 1, 1.5,3) and calculates Pr 1 and Pr2 using the function file in a)Explanation / Answer
(a)
%%%%%%%%%%%%%%%%%
function Pr=Preduced(Vr)
Pr1=8./(3*Vr); % Tr=1
Pr2=16./(3*Vr); %Tr=2
Pr=[Pr1;Pr2]; %Pr will be a matrix with first row giving Pr1 and second row giving Pr2
end
%%%%%%%%%%%%%%%%%%
Save the above function as an m-file with the name 'Preduced.m' in the MATLAB directory.
(b)
%%%%%%%%%%%%%%%%%%%%%%%
Vr=0.5:0.5:3;
Pr=Preduced(Vr)
%%%%%%%%%%%%%%%%%%%%%%%
Save this as a separate script file in the same directory and run it.
You will get:
Pr =
5.3333 2.6667 1.7778 1.3333 1.0667 0.8889
10.6667 5.3333 3.5556 2.6667 2.1333 1.7778
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.