Using MATLAB.................. 1) Consider a gas in a piston-cylinder device in
ID: 3279977 • Letter: U
Question
Using MATLAB..................
1) Consider a gas in a piston-cylinder device in which the temperature is held constant. As the volume of the device was changed, the pressure was measured. The volume and pressure values are reported in the following table: Volume (m3) Pressure (kPa) when T 300 K 2562 1237 801 653 489 412 4 Report all answers in a professional format with units using fprintf and/or disp a) Use linear interpolation to estimate the pressure when the volume is 3.2 m3 b) Use cubic spline interpolation to estimate the pressure when the volume is 3.2 m c) Use linear interpolation to estimate the volume if the pressure is measured to be 1200 kPa. d) Use cubic spline interpolation to estimate the volume if the pressure is measured to be 1200 kPa.Explanation / Answer
'interp1' is used for linear interpolation and 'spline' is used for cubic spline interpolation in matlab.
Linear Interpolation...
>> v=[1,2,3,4,5,6];
>> p=[2562,1237,801,653,489,412];
>> pq = interp1(v,p,3.2);
>> disp(pq)
771.4000
>> pq = spline(v,p,3.2);
>> disp(pq)
763.4267
Cubic spline Interpolation...
>> vq = interp1(p,v,1200);
>> disp(vq)
2.0849
>> vq = spline(p,v,1200);
>> disp(vq)
1.9743