Write a matlab file that uses linear regression to find the value of the univers
ID: 2995074 • Letter: W
Question
Write a matlab file that uses linear regression to find the value of the universal gas constant R in the ideal gas law. See below:
Assume you gathered the following table of temperature and pressure data in your laboratory for a 1 kg (=m) cylinder of nitrogen (standard atomic weight (Wa) of N2 28.014 g/mol) held at a constant volume of 10 m3: Write a MATLAB M-file that uses linear regression to find the the value of the universal gas constant R in ideal gas law: pV = nRT where p = pressure, V = volume, n = moles of gas, and T = temperature in degree K. The M-file must also compute the coefficient of determination for the linear fit to the data and the true relative percent error (epsilon t) between the value of R you find and the standard value found in the literature Turn in a copy of your M-file and a printout of the command window showing your results for R, r2, and epsilon t.Explanation / Answer
T=[234 274 314 354 394 434];
P=[6900 8100 9350 10500 11700 12800];
n=1000/28.014;
V=10;
model=LinearModel.fit(T,P);
R=model.Coefficients.Estimate(2)*V/n
standardR = 8.314;
e=((R-standardR)/standardR)*100
R_square=model.Rsquared
RESULT:
R =
8.2941
e =
-0.2388
R_square =
Ordinary: 0.9997
Adjusted: 0.9996
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.