Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider a gas in a piston-cylinder device in which the temperature is held cons

ID: 3681573 • Letter: C

Question

Consider a gas in a piston-cylinder device in which the temperature is held constant. As the volume of the cylinder (vol) is changed, the pressure (pres) is measured. Write a matlab function with the header [] = myPistonCyl(vol, pres, int) which fits volume-pressure data with first-, second-, third-, and fourth-order polynomials using the polyfit function. Plot your results on the same graph Plot the actual data as a circle with no line Calculate the values to plot prom your polynomial regression results at intervals of int. Do not show the calculated values on the plot, but do connect the points with solid lines.

Test Case: >> vol = 1:6; >> pres = [2494 1247 831 623 499 416]; >> myPistonCyl(vol, pres, 0.2) *matlab

Explanation / Answer

Code to copy

For T=300K,

Matlab script is as follow:

% inputting data corresponding to temperature T=300 and 400K
V=[1 2 3 4 5 6];
P300=[2494 1247 831 623 499 416];
P400=[4157 2078 1386 1039 831 693];
V1=1:0.2:6;
% (a)creating new pressure set P300l, by means of linear interpolation
P300l=interp1(V,P300,V1);
%(b) spline interpolation
P300s = spline(V,P300,V1);
% plotting m,p
plot(V,P300,'o',V1,P300s,V1,P300l)
legend('actual data','cubic interpolation','linear interpolation');

For T=400K

% for T=400K
% (m)creating new pressure set P400l, with linear interpolation
P400l=interp1(V,P400,V1);
%(p) spline interpolation
P400s = spline(V,P400,V1);
% plotting m,p
plot(V,P400,'o',V1,P400s,V1,P400l)
legend('actual data','cubic interpolation','linear interpolation');

% decision polynomial fits for T=300K
p1=polyfit(V,P300,1);
p2=polyfit(V,P300,2);
p3=ployfit(V,P300,3);
p4=ployfit(V,P300,4);
% original pressure data consequent to polynomial fits
n=(6-1)/0.2+1;
for x=1:n
pp300(1,x)=p1(1)+p1(2)*V1(x);
pp300(2,x)=p2(1)+p2(2)*V1(x)+p2(3)*V1(x)^2;
pp300(3,x)=p3(1)+p3(2)*V1(x)+p3(3)*V1(x)^2+p3(3)*V1(x)^3;
pp300(4,x)=p4(1)+p4(2)*V1(x)+p4(3)*V1(x)^2+p3(3)*V1(x)^3+p3(3)*V1(x)^4;
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote