Question
please screenshot the MATlab code if possible
The following equation is available for the saturation pressure of air as a function of temperature: In (psat/Pc) = C1 x + C2

Need ASAP

it is for a course that uses MATlab to solve for missing variables and such.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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.

Given eq in (96%) = 4,4+** Shu (test) where that and Pc = 3.77 MPa, To= 182.5k Let Z = ln en lehet egy Y = ln (Teat) z = GataC Σα + C2 Σ+ G, ΣΥΞ ΣΖ ΕΙΣ? + C, Σ2 3 4. C3 ΣυY = ΣκZ 6, Ση - , Σ+ Σκάγο Σηθ 2. Σ Ση2 EX Ο, Σ? Σχ ΣκY Enz ζω και Ση 3 Ση EnzStandard enor of estimate Se Jo  [ Y: - ce+b+c)] 2 given value fitted value Co-relation coefficient, 8= n-1 (4:- =) (9:-5) 5

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');

Psat vs Tsat 3.5 Data Points Regression Fit 3 2.5 1 0.5 - 0 70 80 90 100 110 120 130 Tsat (K)MATLAB R2015a HOME PLOTS APPS EDITOR PUBLISH VIEW EDIT RUN 38 II - Find Files Insert fx Fli Run Section Compare Go To Comment

Add a comment
Know the answer?
Add Answer to:
please screenshot the MATlab code if possible Need ASAP it is for a course that uses...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • screenshot MATlab code please The following equation is available for the saturation pressure of air as...

    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...

    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)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT