Question: Please modify my code ( MY CODE BELOW) using the built-in MATLAB functions spline and ppval to build a clamped spline that solves the problem

Please modify my code (MY CODE BELOW) using the built-in MATLAB functions spline and ppval to build a clamped spline that solves the problem. Here is an example script from Mathworks.com to get you started.

x=-4:4; y=[0 .15 1.12 2.36 2.36 1.46 .49 .06 0]; clamped=spline(x,[0 y 0]); xx=linspace(-4,4,101); plot(x,y,o,xx,ppval(clamped,xx),-); 

Use 50 equispaced points for this problem.

MAT 340 NUMERICAL METHODS. THANKS IN ADVANCE!

f=@(x) 1./(1+10.*x.^2);

X=linspace(-1,1); %% domain in order to plot

%% s for the error

s=linspace(0,1);

plot(X,f(X),'k','lineWidth',3)

hold on

for n=3:12

x=linspace(-1,1,n+1);

y=f(x);

P=lagrangepoly(x,y);

plot(X,P(X),'--')

n

Error_n=max(abs(f(s)-P(s)))

end

%%

% The error was decreasing up until the odd n's up until 7 and increasing for even n's

% For n=100 the error should be large

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!