steamtables - hold off pause %Quadratic Interpolation...

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

View Full Document Right Arrow Icon
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');
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: hold off 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); y=@(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,'0'); title('Inverse Interpolation') legend('ex data','regression','inverse inter. pt'); xlabel('specific volume (k'); ylabel('entropy');...
View Full Document

Page1 / 2

steamtables - hold off pause %Quadratic Interpolation...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online