Least Square method is regression method which is used to fit data (calculate coefficients of polynomial to be fitted)
It is done by finding A and B matrices. Summation is taken here is over given number of data points,
Procedure is given below
For simplification some substitution are done.
MATLAB CODE FOR regression fit
leastSqRegression.m
clc;
%MALAB CODE for finding least square regression
% data given Tsat and Psat
T=[76.5 80.4 83.3 85.7 88.1 90.2 92 93.6 95.1 96.5 98.9 101
...
103 106.3 109.2 111.8 114.2 116.4 118.4 122.9 127];
P=[0.08 0.12 0.16 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.6 ...
0.7 0.8 1 1.2 1.4 1.6 1.8 2 2.5 3];
% Constant values Critical Pressure and Critical Temperature
Pc=3.77;
Tc=132.5;
%define x
x=(1/Tc)-(1./T);
%define Y as ln(Tsat/Tc)
Y=log(T/Tc);
%define Z as ln(Psat/Pc)
Z=log(P/Pc);
% Coefficient Matrix A
A=[sum(x) sum(x.^2) sum(Y);sum(x.^2) sum(x.^3) sum(x.*Y);sum(x.^3)
sum(x.^4) sum(x.^2.*Y) ];
B=[sum(Z);sum(x.*Z);sum(x.^2.*Z) ];
phi=A\B;
c1=phi(1);
fprintf('Value of C1 is = %f ',c1);
c2=phi(2);
fprintf('\nValue of C2 is = %f ',c2);
c3=phi(3);
fprintf('\nValue of C3 is = %f ',c3);
% Standard error of estimation
x_1=(1/Tc)-(1./T);
Z_new=c1*x_1+c2*x_1.^2+c3*log(T/Tc);
P_Cal=exp(Z_new)*Pc;
n=length(T);
Se=sqrt(sum((P-P_Cal).^2)/(n-2));
fprintf('\nStandard error of estimate = %f ',Se);
%Corelation coefficient
A=sum((T-mean(T)).*(P_Cal-mean(P_Cal)))/(n-1);
r=A/(std(T)*std(P_Cal));
fprintf('\nCorelation Coeficient = %f ',r);
% Coefficient of Determination
Coe_det=r^2;
fprintf('\nCoeficient of Determination = %f ',Coe_det);
plot(T,P,'dr'); hold on
T_finer=76.5:0.1:127;
x_1=(1/Tc)-(1./T_finer);
Z_new=c1*x_1+c2*x_1.^2+c3*log(T_finer/Tc);
P_finer=exp(Z_new)*Pc;
plot(T_finer,P_finer,'-b','LineWidth',1.5);
legend('Data Points','Regression Fit');
xlabel('Tsat (K)');
ylabel('Psat (MPa)');
title('Psat vs Tsat');
please screenshot the MATlab code if possible Need ASAP it is for a course that uses...
screenshot MATlab code please The following equation is available for the saturation pressure of air as a function of temperature: In (psat/Pc) = C1 x + C2 x? + C3 In (Tsat/Tc), where x = 1/Tc - 1/Tsat Pc =3.77 MPa is the critical pressure, and Tc = 132.5 K is the critical temperature. The following data are available for the saturation pressure of air as a function of temperature: Tsat (K) psat (MPa) Taat (K) paat (MPa) 76.5 80.4...
Needed ASAP A Matlab solution is required please screenshot solution The following equation is available for the saturation pressure of air as a function of temperature: In (psat/Pc) = C1 x + C2 x2 + C3 In (Tsat/Tc), where x = 1/Tc - 1/Tsat Pc =3.77 MPa is the critical pressure, and Tc = 132.5 K is the critical temperature. The following data are available for the saturation pressure of air as a function of temperature: Taat (K) psat (MPa)...