Question: Solve using the given codes as shown of fig 2. Transform first the equation to linear basis function models and the find the value of
Solve using the given codes as shown of fig 2. Transform first the equation to linear basis function models and the find the value of a and b. On the given codes, modify only the phi, w, a, b and yp. Use matlab codes


Thursday, February 11, 2021 (3) [30 points] A certain gas was monitored by recording its pressure and volume on 4 occasions. Using the following cubic virial equation of state for real gases, calculate the constants A and B that best fits the given PV data. Use R = 0.08206 L atm/mol K and T = 303 K. Virial EOS: PV A = 1+ RT B V2 Hint: Put the model in linear basis function form, and then figure out the basis functions and the target y variable before doing the regression. P (atm) V (L) 0.985 25 1 108 22 1363 18 1631 15 1 X - [3; 4.5; 6; 7.5; 9; 10.5); 2 [@.051; 0.064; 0.071; 0.079; 0.082; 0.991]: 3 4 % Perform least-squares regression 5 phi (x) [x(1) X(1)*x(2)]: 6 PHI = cell mat(arrayfunce(j) phi([x(j) y)]), (1:length(x))", "Uni',0); 7 * = (PHI'+PHI) (PHI'); 8 9 % Display Results 10 W(1): 11 b- -W(2); 12 fprintf("Parameters: a = %.3f b - %.3f ',a,b); 13 xp - linspace(x(1),x(end), 100); 14 aExp./(1+b^xp); 15 16 % Calculate R2 17 yp - a*x./(1bx): 18 RZ = 1 - sumc(y-yp). 2)/sumy mean(y)).^2); 19 fprintf(R2: %.4f ',R2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
