steamtables

This preview shows pages 1–2. Sign up to view the full content.

function steamtables(v1,s1,z,v2,s2,xx) %Problem 15.7 %This Program calculates the corresponding entropy for a specific volume,z %passed into the function using linear interpolaiton(v1,s1) %need only two points. %Using quadratic interpolation (v2,s2). %Using inverse interpolation given a value of entropy,x passed into %function(v2,s2). % %values of entropy (s1 % s2) units (kJ/(kg K)) %These values correspond to superheated vapor at 200 Mpa. %Linear Interplation p=polyfit(v1,s1,1); %Finds coeff of 1st degree polynomial va=polyval(p,z); %Finds interpolated value after coeff have been determined. fprintf('\n(a) %5.4f\n',va); y=p(2)+p(1).*v1; plot(v1,s1,'o',v1,y,'b'); xlabel('specific volume'); ylabel('entropy'); hold on; grid pause plot(z,va,'o g'); legend('ex data','linear regression','interpolated point'); title('linear interpolation'); hold off

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: pause %Quadratic Interpolation p=polyfit(v2,s2,2); %Finds coeff of 2st degree polynomial va=polyval(p,z); %Finds interpolated value after coeff have been determined. fprintf('\n(b) %5.4f\n',va); y2=p(3)+p(2).*v2+p(1).*v2.^2; plot(v2,s2,'o',v2,y2,'b'); xlabel('specific volume'); ylabel('entropy'); hold on; grid pause plot(z,va,'o g'); legend('ex data','regression','interpolated point'); title('Quadratic Interpolation'); hold off pause %Volume corresponding to an entropy passed into funcion ,x, using inverse %interpolation. p=polyfit(v2,s2,2); [email protected](x) p(3)-xx+p(2).*x+p(1).*x.^2; root=bisection2(y,0.1,1,.00001,1000); plot(v2,s2,'o',v2,y2,'b',root,xx,'o'); title('Inverse Interpolation') legend('ex data','regression','inverse inter. pt'); xlabel('specific volume (m^3/kg)'); ylabel('entropy (kJ/(kg k))'); grid fprintf('\n(c) %5.4f\n\n',root);...
View Full Document

{[ snackBarMessage ]}