HW_9_Solution - for i=1:length(t_int)...

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

View Full Document Right Arrow Icon
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
HOMEWORK#9 2) Lagrange.m function [P]=Lagrange(x,y,x0) n=length(x); P=0; for j=1:n L(j)=1; for k=1:n if j~=k L(j)=L(j)*(x0-x(k))/(x(j)-x(k)); end end P=P+L(j)*y(j); end Sealevel.m fid = fopen( 'sea_level.txt' , 'rt' ) h1 = fgetl(fid); h2 = fgetl(fid); h3 = fgetl(fid); h4 = fgetl(fid); h5 = fgetl(fid); d = fscanf(fid, '%f' ); d = reshape(d,[2 6])'; T=d(:,1); O=d(:,2); t_eval=19; P=Lagrange(T,O,t_eval); t_int=0.1:0.1:39.9;
Background image of page 5

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

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

Unformatted text preview: for i=1:length(t_int) P(i)=Lagrange(T,O,t_int(i)); end plot(T, O, 'ro' ,t_int,P, 'k-' ) title( 'Sea Level Oxygen Concentration' ) xlabel( 'Temperature-C' , 'fontsize' ,12) ylabel( 'Oxygen Concentration-mg/L' , 'fontsize' ,12) Solution P = 9.2762 5 10 15 20 25 30 35 40 6 7 8 9 10 11 12 13 14 15 Sea Level Oxygen Concentration Temperature-C Oxygen Concentration-mg/L...
View Full Document

Page1 / 6

HW_9_Solution - for i=1:length(t_int)...

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

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