Question

)10 12 32-5272-92130 180 230280330 temperature, T (°C) 15.3 15.2915.28 15.27 15.2615.22 15.1414.19 13.3112.9 knots index, i d

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is Code:

function y=natural_cubic_spline_interp(x1,y1,x)
%x1=independent variable;x2=dependent variable;x=value at which we have to
%find the dependent variable;y=corresponding value of dependent variable at x;
y = spline(x1,y1,x);
end

clear all
close all
z=[-12 -32 -52 -72 -92 -130 -180 -230 -280 -330];
T=[15.31 15.31 15.32 15.32 15.32 15.22 15.14 14.19 13.31 12.9];

depth=[-330:2:-10];
for i=1:length(depth)
temp_LPI(i)=lagrange_interp(z,T,depth(i));
end
hold on
plot(z,T,'*')
plot(depth,temp_LPI,'b')

for i=1:length(depth)
temp_NDD(i)=newtondivdiff_interp(z,T,depth(i));
end
plot(depth,temp_NDD,'--g')

for i=1:length(depth)
temp_nCS(i)=natural_cubic_spline_interp(z,T,depth(i));
end
plot(depth,temp_nCS,'k')
title('Depth Vs. Temperature plot')
xlabel('Depth in meter')
ylabel('Temperature in degree c')
legend('Nodes','Lagrange','Newton','Cubic Spline','Location','best')
temp_LP=lagrange_interp(depth, temp_LPI,-150);
fprintf('\nThe temperature value at z=-150 m using Lagrange interpolation is %f \n',temp_LP)
temp_ND=newtondivdiff_interp(depth, temp_NDD,-150);
fprintf('\nThe temperature value at z=-150 m using Newton interpolation is %f \n',temp_ND)
temp_sp=natural_cubic_spline_interp(depth, temp_nCS,-150);
fprintf('\nThe temperature value at z=-150 m using Cubic Spline interpolation is %f \n',temp_sp)

Add a comment
Know the answer?
Add Answer to:
)10 12 32-5272-92130 180 230280330 temperature, T (°C) 15.3 15.2915.28 15.27 15.2615.22 15.1414.19 13.3112.9 knots index, i depth, z (m) 3 6i Table 1: Temperature of seawater in the upper layer of th...
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
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