Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am using matlab. please help me to fix the code to pass the last two errors Write a MAtlab function, called Lagrange_poly that inputs
I am using matlab. please help me to fix the code to pass the last two errors
Write a MAtlab function, called Lagrange_poly that inputs a set of data points (x,y)=( datx, daty), a set x of numbers at which to interpolate, and outputs the polynomial interpolant, y, evaluated at x using Lagrange polynomial interpolation. Your function header should look something like: function y= Lagrange_poly (x, dat x, daty ) Use the code you developed to interpolate the functions f1(x)=exp{x2},f2(x)=1/(1+x2) using the data points dat x=3:1:3. Interpolate at the points x=3:0.01:3. Call P1 the Lagrange interpolant of f1, and P2 the Lagrange interpolant of f2. Repeat the experiment except using the data datx1=-3:0.5:3. Call in that case P3 and P4 the new interpolants. Compare your answer for this problem to what you got previously. For each interpolation problem, plot on the same graph the function, the two interpolants, and the data set (use the function scatter). Comment the results in your matlab script using % Output Previous Assessment: 1 of 3 Tests Passed Respect guidelines x Test P1, P2 Variable P1 must be of size [601 1]. It is currently of size [1 1]. Check where the variable is assigned a value. Test P3, P4 The submission must contain a variable named P3Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started