Matlab

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

N= 4; % numero de puntos

x = [2; 2.5; 4; 5; 7];


f =[0.5; 0.4; 0.25;0.2; 0.142];
x
f
t=linspace(-10,10,100);
Pt=0;
for i=1:(N+1)
phi=1;
for k=1:(N+1)
if k~=i;
termphi=(t-x(k))/(x(i)-x(k));
phi=phi.*termphi;
end
end
term=exp(i)*phi;
Pt=Pt+term;
end
fprintf('Px=%.10f \n',Pt)
xlabel('Dominio');
ylabel('Rango');
plot(x,f,'*');
hold on
plot(t,Pt,'y');

You might also like