Applied Physics Department, FAS, HCMUT Matlab Projects – Physics 1
Project 7:
Determining the work of the thermodynamic system in polytropic
processes pVk=const.
1. Content
The work of an ideal gas thermodynamic system in a polytropic process is defined as follows:
With k = 0: isobaric process, k = 1: isothermal process, k = : adiabatic process; k = : isochoric
process. This project requires students to use Matlab to represent the graph (P, V) of the above
processes from given P and V values and thereby calculate the work done by the processes.
2. Requirements
1) Students should have basic programming knowledge of MATLAB.
2) Learn about symbolic calculation and graphical interpretation in MATLAB.
3. Tasks
Write Matlab program to:
1) Enter data for number of gas moles n, initial pressure P0, initial volume V0.
2) Create a button to select the process (polytropic, isothermal, isothermic or exit) and enter
values of P and V for selected process. (You can refer to the command line below or create a
GUI interface)
3) Draw a graph of the above process on the scale (P, V).
4) Use symbolic operations to calculate the work of selected process.
Note: Students can use other non-symbolic approaches.
Submitting report has to contain text explaining the content of the program and the entire code
verified to run properly in Matlab.
4. References:
A. L. Garcia and C. Penland, MATLAB Projects for Scientists and Engineers, Prentice Hall,
Upper Saddle River, NJ, 1996. http://www.algarcia.org/fishbane/fishbane.html. Or
https://www.mathworks.com/matlabcentral/fileexchange/2268-projects-for-scientists-and-
engineers
%@ Select type of path (isobar, isochore or isotherm) or quit
iPoint = iPoint + 1; % Next point
fprintf('For leg #%g \n',iPoint-1);
PathType = menu(sprintf('Leg %g: Select next path',iPoint-1), ...
'Isobar (Constant P)', 'Isochore (Constant V)', ...
'Isotherm (Select new V)','QUIT');
%@ If the next path leg is an isobar (Constant P)
if( PathType == 1 )
close(gcf); % Close the figure window
%@ Determine the new volume, pressure and temperature
V(iPoint) = input('Enter new volume: ');
P(iPoint) = P(iPoint-1); % New pressure same as old pressure
T(iPoint) = P(iPoint)*V(iPoint)/(nMoles*R); % New temperature
%@ Compute the work on done an isobar
W = P(iPoint)*( V(iPoint) - V(iPoint-1) );
%@ Add volume and pressure to plot data
VPlot = [VPlot V(iPoint)]; % Add points to volume data for plotting
1/1
Applied Physics Department, FAS, HCMUT Matlab Projects – Physics 1
PPlot = [PPlot P(iPoint)]; % Add points to pressure data for plotting
%@ else if the next path leg is an isochore (Constant V)
elseif( PathType == 2 )
close(gcf); % Close the figure window
%@ Determine the new volume, pressure and temperature
1/2