`Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
% a. Define the necessary symbolic variables.
clear, clc
[L,LE,S,SE]=interpolated(1)
function [L,LE,S,SE]=interpolated(x)
XX=[0:0.5:2];
Y=[0,0.5205,0.8427,0.9661,0.9953];
min=inf;
ind=-1;
for i=1:length(XX)-2
if(min>norm(XX(i:i+2)-x))
ind=i;
end
end
L=lagrangeInterp(XX(ind:ind+2),Y(ind:ind+2),x);
LE=abs(L-erf(x));
S=interp1(XX,Y,x,'spline');
SE=abs(S-erf(x));
function [yhat]=lagrangeInterp(x,y,interpx)
X=x;
f=y;
x=interpx;
l=0;
for i=1:length(X)
li=1;
for j=1:length(X)
if i~=j
li=(li).*((x-X(j))/(X(i)-X(j)));
end
end
l=(l)+((li)*f(i));
end
yhat=l;
end
end
Kindly revert for any queries
Thanks.
matlab The error function is a mathematical function that frequently arises in probability and statistics. It also c...
IN MATLAB Write a MATLAB function that can be used by a user to perform polynomial interpolation using Lagrange Interpolation Method on a set of data. You should name your function as YourInitials_Lagrange_interpolation. 1. FUNCTION INPUT: . The input data pairs x and f(x) should be expressed as vectors and are used to construct the interpolation polynomials The interpolating data points/value The order of interpolating polynomials to be used. For this project you code should handle first order, second order...
matlab matlab For this problem you will test a few interpolation approaches for the application of generating interpolated data. We'll do this by interpolating data that is sampled from a known mathematical function. The same function can then be used to compute true values at the interpolated points to use in error Consider the following mathematical function (Runge's function): 1+25r2 Write a function mfile that uses this formula to generate a set of data use those points along approaches outlined...
Create a MATLAB function to perform Lagrange Interpolation. Your function will be used as illustrated below: >> ya = Lagrange(x, y, a) where "x" is a vector of ? independent data values, "y" is a vector of ? dependent function values corresponding to "x", "a" is an arbitrary value of "x" for which you want to know the Westimate of "y", and "ya" is the estimate of the function at x=a. Print an error message and exit the function if...