PROGRAMMING IN MATLAB: 1. (8 points) Consider a gas in a piston-cylinder device
ID: 3681346 • Letter: P
Question
PROGRAMMING IN MATLAB: 1. (8 points) Consider a gas in a piston-cylinder device in which the temperature is held constant volume of the cylinder (vo1) is changed, the pressure (pres) is measured. Write a function with the header As the [] = 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) Figure 1 Eile Edit yiew Insert Iools Desktop Window Help Piston-cylinder device at T = 300K 2500 O Data 1storder 2nd order 3rd order 4th order 2000 1500 1000 500 1 1.5 2 25 335 4 455 55 6 Volume, mExplanation / Answer
p = polyfit(x,y,n) returns the coefficients for a polynomial p(x) of degree n that is a best fit (in a least-squares sense) for the data in y. The coefficients in p are in descending powers, and the length of p is n+1
here n is the integer value not a reail value
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.