Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1 Polynomial interpolation (25 points) Download the starter code HW5p1.m from CANVAS Files section folder HW Problems to your computer, and rename it as

image text in transcribed
image text in transcribed
Problem 1 Polynomial interpolation (25 points) Download the starter code HW5p1.m from CANVAS Files section folder "HW Problems" to your computer, and rename it as Yourlastname YourfirstnameHW5p1.m. This homework problem only requires you to complete two lines of this starter code as follows. For each n 5,6,7, the starter code generates n uniformly spaced data points in the interval [-1, 1) and plots them as different colored circular markers (red for n = 5, green for n = 6, and blue for n = 7). Watch out for overlapping markers. For each n, you need to compute and plot an interpolating polynomial in the corresponding colored lineplot. To do so, uncomment and complete the lines 20 and 21 in the starter code. Then uncomment lines 23, 25, 27. Other than completing the lines 20-21, and uncommenting lines 23, 25, 27, you are NOT allowed to change or add anything else in the starter code. You should be able to verify the correctness of your lines 20-21 by examining the plot that the completed code generates (and reviewing the concepts learnt in Lec. 9). close all; clear; clc; 2 3 - 4 5- 6 7 - set (groot, 'defaultAxesTickLabelInterpreter', 'latex'); set (groot, 'defaulttextinterpreter', 'latex'); set (groot, 'defaultLegendInterpreter latex'); 1 n = 5:7; - 9 10 11 - 12 13 - 14 - 15 16 - 17 - 18 19 20 21 22 23 24 CC = {'r','g', '6'}; for k=1: length(n) x = linspace(-1,1,n(k))'; y = 1./(1 + 25*x.^2); plot(x,y,'o', 'MarkerSize', 12, 'MarkerEdgeColor', 'k', 'MarkerfaceColor',cc{ set (gca, 'FontSize',30) xlabell'sxs', 'FontSize",25); ylabel('sys', 'FontSize', 25, 'rotation', 0); hold on % complete the following lines % X = ; * the coefficient matrix C=; the coefficient vector 25 xnew = linspace(-1,1,588); * evaluate the interpolated polynomial at xnew * ynew = polyval(flipud(c),xnew); s plot(xnew, ynew,'color'.cc{k}, 'LineWidth', 2) end 26 27 28 29

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions