Question

In Matlab, Construct the natural cubic spline (see the LiveScript) to interpolate the Runge function (see...

In Matlab,

Construct the natural cubic spline (see the LiveScript) to interpolate the Runge function (see Homework 6) using 10, 15, 20, and 25 equispaced nodes.

Homework Answers

Answer #1

MATLAB Code:

close all
clear
clc

xx = linspace(-1, 1, 1000);
yy = 1 ./ (1 + 25*xx.^2);
figure, hold on
plot(xx, yy), xlabel('x'), ylabel('f(x)')
title('Cubic Spline Interpolation')

N = [10 15 20 25];
for i = 1:length(N)
n = N(i);
x = linspace(-1, 1, n);
f = 1 ./ (1 + 25*x.^2);
yy = spline(x, f, xx);
plot(xx, yy)
end
legend('Actual Function', 'N = 10 nodes', 'N = 15 nodes', 'N = 20 nodes', 'N = 25 nodes')

Plots:

Zoomed versions of the above plot:

Know the answer?
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
Similar Questions
Develop, debug and test a program in Matlab to implement cubic spline interpolation. Calculate f(2.25) utilizing...
Develop, debug and test a program in Matlab to implement cubic spline interpolation. Calculate f(2.25) utilizing the data x = 1.6, 2, 2.5, 3.2, 4, 4.5 f(x) = 2, 8, 14, 15, 8, 2 USE MATLAB CODE
Modify this Matlab code for natural spline so it computes clamp Spline compclampspline(x,y,alpha,beta) alpha and beta...
Modify this Matlab code for natural spline so it computes clamp Spline compclampspline(x,y,alpha,beta) alpha and beta are the derivatives at the ends. Code for Natural Spline function [a,b,c,d]=compnatspline(x,y) function [a,b,c,d]=compnatspline(x,y) n=length(x); delx=(x(2:n)-x(1:n-1))'; dely=(y(2:n)-y(1:n-1))'; a=zeros(n,n); a(1,1)=1; a(n,n)=1; r(1)=0; r(n)=0; for row=2:n-1 r(row)=3*(dely(row)/delx(row)-dely(row-1)/delx(row-1)); a(row,row-1)=delx(row-1); a(row,row)=2*(delx(row-1)+delx(row)); a(row,row+1)=delx(row); end c=a\r'; clear a b(1:n-1)=dely./delx -delx/3.*(2*c(1:n-1)+c(2:n)); d(1:n-1)=(c(2:n)-c(1:n-1))./(3*delx(1:n-1)); a(1:n-1)=y(1:n-1); c=c(1:n-1);
Compute the x and y coordinate of the Point P(t=0.2)P(t=0.2) on the cubic B-Spline P(t)=∑nk=1PkBk,4(t)P(t)=∑k=1nPkBk,4(t) Control...
Compute the x and y coordinate of the Point P(t=0.2)P(t=0.2) on the cubic B-Spline P(t)=∑nk=1PkBk,4(t)P(t)=∑k=1nPkBk,4(t) Control Points: P1P1 = ( 3|5), P2P2 = ( 6|6), P3P3 = ( 7|10), P4P4 = ( 20|11) Use the following blending functions B0,4=16(1−3t+3t2−t3)B0,4=16(1−3t+3t2−t3) B1,4=16(4−6t2+3t3)B1,4=16(4−6t2+3t3) B2,4=16(1+3t+3t2−3t3)B2,4=16(1+3t+3t2−3t3) B3,4=16(t3)B3,4=16(t3) Px = PY= Show in steps complete calculation
a.   Which functional form (linear, quadratic, cubic) is most suitable to your data? Construct a scatter...
a.   Which functional form (linear, quadratic, cubic) is most suitable to your data? Construct a scatter diagram but be sure to just do the dots, don’t include the lines that connect them. Then, play around with the trendline feature and include what you consider to be the best trendline. b.   Using OLS, estimate the firm’s short-run production function. Comment on the strength of the regression results. c.   Calculate the Q, AP, and MP for L = 8 workers. d.   At...
6. Using the class data (see Blackboard file - "Class Survey Data - PSS-10 and GAS")...
6. Using the class data (see Blackboard file - "Class Survey Data - PSS-10 and GAS") calculate the correlation between the GAS – Goal disengagement and the GAS – Goal reengagement scores. Write the results in a statistical statement. 7. Using the class data calculate the correlation between the GAS – Goal disengagement and the PSS-10 scores. Write the results in a statistical statement. 8. Using the class data calculate the correlation between the GAS – Goal reengagement scores and...
It is possible to construct oscillatory wave packets without using trigonometric functions. Consider the function y(x)...
It is possible to construct oscillatory wave packets without using trigonometric functions. Consider the function y(x) = (64x^6 - 240x^4 + 180x^2 - 15)*e^(-x^2). Wave packets using polynomials occur in quantum mechanics as solutions to the simple harmonic oscillator and the hydrogen atom, as we discuss later in this test. (a) Sketch this function in the region where it has reasonably large amplitude. (b) What is the width of this wave packet? Make a rough estimate from your sketch. (c)...
Solve the following problem using the MATLAB environment Write a function [approx_root, num_its] = bisection(f,a,b,tol) that...
Solve the following problem using the MATLAB environment Write a function [approx_root, num_its] = bisection(f,a,b,tol) that implements the bisection method. You function should take as input 4 arguments with the last argument being optional, i.e, if the user does not provide the accuracy tol use a default of 1.0e-6 (use varargin to attain this). Your function should output the approximate root, approx_root and the number of iterations it took to attain the root, num_its. However, if the user calls the...
​a) Construct a​ 95% confidence interval for the regression coefficient for x1 and interpret its meaning....
​a) Construct a​ 95% confidence interval for the regression coefficient for x1 and interpret its meaning. n=? k=? critical t score? Calculate the upper confidence limit​ (UCL) by using the ​"plus+​" component of the equation. Calculate the lower confidence limit​ (LCL) by using the ​"minus−​" component of the equation. b) Construct a​ 95% confidence interval for the regression coefficient for x2 and interpret its meaning. Calculate the upper confidence limit​ (UCL) by using the ​"plus+​" component of the equation. Calculate...
Write a function count_div5(nested_list) that takes in a list of lists of integers, and returns a...
Write a function count_div5(nested_list) that takes in a list of lists of integers, and returns a list of integers representing how many integers in each sublist of the original were divisible by 5. Examples: >>> count_div5([[5, 3, 25, 4], [46, 7], [5, 10, 15]]) [2, 0, 3] >>> count_div5([]) [] >>> count_div5([[-20, 10, 2, 4, 5], [], [5], [8, 25, 10], [6]]) [3, 0, 1, 2, 0]
You want to see if there are more imported cars in the faculty or the student...
You want to see if there are more imported cars in the faculty or the student parking lot. You examine 5 different student and faculty lots and randomly select 20 cars in each. You then looked to see how many of those cars were imported. Make a figure comparing the data below. Calculate the average, standard deviation, and the standard error and graph that accordingly. Please include figure caption. Number of imported cars Student Lots Faculty Lots 6 12 8...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT