Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Please generate the data set to approximate mountain everest using cubic spline. The two codes to generate the cubic spline are below, just set up

Please generate the data set to approximate mountain everest using cubic spline. The two codes to generate the cubic spline are below, just set up the data points based on the mountain picture

image text in transcribedimage text in transcribed

function z = cspline(t,y) % a simple Gaussian Elimination procedure, especially designed for this tridiagonal system, n = length(t); z = zeros(n,1); h = zeros(n-1,1); b = zeros(n-1,1); u = zeros(n,1); v = zeros(n,1); h = t(2:n)-t(1:n-1); b = (y(2:n)-y(1:n-1))./h; u(2)= 2*(h(1)+h(2)); % diagonal of H matrix v(2) = 6*(b(2)-b(1)); % the right-hand side vector % Gaussian Elimination. Forward Elimination for i=3:n-1 u(i) = 2*(h(i)+h(i-1))-h(i-1)^2/u(i-1); v(i) = 6*(b(i)-b(i-1))-h(i-1)*v(i-1)/u(i-1); end % Backward substitution for i=n-1:-1:2 z(i) = (v(i)-h(i)*z(i+1))/u(i); end

evaluatiing the cubic spline with x_vec

function S = cspline_evalx(t,y,z,x_vec) % function S = cepline_eval (t, y, z,x_vec) % compute the value of the natural cubic spline % at the points x_vec when t , y, z are given m = length(x_vec); S = zeros(size(x_vec)); n = length(t); for j=1:m x = x_vec(j); for i=n-1 :-1: 1 if (x-t (i)) >= 0 break end end h =t(i+1)-t (i); S(j)=z(i+1)/(6*h)*(x-t(i))^3-z(i)/(6*h)*(x-t (i+1))... +(y (i+1)/h-z(i+1)*h/6)*(x-t(i))... -(y(i)/h-z(i)*h/6)*(x-t (i+1)); end end

thus you need to generate points to plot the mountain using the cubic spline

Problem 4: Natural Cubic Spline in Matlab The goal of this problem is to draw Mount Everest with the help of natural cubic splines. We have a rather poor quality photo of the mountain profile, which is given below. You need to set up a coordinate system, and select a set of knots along the edge of the mountain, and find the coordinates for all these interpolating points. We are aware that the mountain profiles are not very clear in that photo, so please use your imagination when you find these approximate points. You may either print out the mountain picture and work on it on a piece of paper, or send the image to some software and locate the coordinates of the interpolating points. Make sure to select at least 20 points. You may use more points if you see fit. After you have generated your data set, you need to find a natural cubic spline interpolation. Use the functions cspline and cspline eval, which are available in Section 3.4. Read these two functions carefully, try to understand them before using them. Does it look like there is a smaller peak on the right? Does the peak look rather sharp? How would you deal with this situation, knowing that a single cubic spline function will generate a "smoothest" possible interpolation? What you need to hand in: A Matlab script that contains your data set, compute the spline functions, and draw the mountain. Also the plot of your Mount Everest. Have Fun! Fig. 3.3 Natural cubic spline, for Mount Everest. Problem 4: Natural Cubic Spline in Matlab The goal of this problem is to draw Mount Everest with the help of natural cubic splines. We have a rather poor quality photo of the mountain profile, which is given below. You need to set up a coordinate system, and select a set of knots along the edge of the mountain, and find the coordinates for all these interpolating points. We are aware that the mountain profiles are not very clear in that photo, so please use your imagination when you find these approximate points. You may either print out the mountain picture and work on it on a piece of paper, or send the image to some software and locate the coordinates of the interpolating points. Make sure to select at least 20 points. You may use more points if you see fit. After you have generated your data set, you need to find a natural cubic spline interpolation. Use the functions cspline and cspline eval, which are available in Section 3.4. Read these two functions carefully, try to understand them before using them. Does it look like there is a smaller peak on the right? Does the peak look rather sharp? How would you deal with this situation, knowing that a single cubic spline function will generate a "smoothest" possible interpolation? What you need to hand in: A Matlab script that contains your data set, compute the spline functions, and draw the mountain. Also the plot of your Mount Everest. Have Fun! Fig. 3.3 Natural cubic spline, for Mount Everest

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions