Write a function in MATLAB called WORKDONE to calculate the area under the curve of a PV diagram for a thermodynamic process, based on a single input, κ, the specific heat ratio. The values for P and V are defined below. The output of the function should be a single number equal to the area under the curve, found using the trapz command. Include these parameters in your function: V=0.001:0.001:0.02
P = 380/V^k
Following is the code in WORKDONE.m :
function res = WORKDONE(k)
%
% Write the given definitions.
%
V = 0.001 : 0.001 : 0.02;
%
% While writing P, we must use dot-notations so that P is also a
% vector.
%
P = 380 ./ (V .^ k);
%
% The work done is the area of P-V graph with the V-axis.
% Thus, while using Matlab's trapz() method, we pass P as a vector.
%
res = trapz(P);
end
Following are some sample runs :
>>
>> WORKDONE(1)
ans =
1.1676e+06
>> WORKDONE(0.1)
ans =
1.1651e+04
>> WORKDONE(12.3)
ans =
1.5098e+39
>>
Get Answers For Free
Most questions answered within 1 hours.