Question
matlab
The error function is a mathematical function that frequently arises in probability and statistics. It also can show up in th
0 0
Add a comment Improve this question Transcribed image text
Answer #1

`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

MATLAB R2018a 1 di T (魁ㄅㄧ , e, 3 rch Documentation EDITOR Find Files Run Section ie Compare ▼ [a Go To▼ Comment % Advance Run

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
matlab The error function is a mathematical function that frequently arises in probability and statistics. It also c...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT