永利皇宫官网网址

网站最新上线:http://www.hslogic.com/

牛顿Newton插值 MATLAB源程序代码

上一篇 / 下一篇  2017-11-14 00:11:06

function Newton_main()
clc
x=0:1:10;
y=x./(tan(x)+1);
k=1;
for x0=0:0.01:10;
    y0(k)=Newton(x,y,x0);
    k=k+1;
end
x0=0:0.01:10;
plot(x0,y0)
hold on 
scatter(x,y,'ro')
msgbox('MATLAB编程答疑,请加QQ: 1747812398','MATLAB答疑','help')
web http://www.360matlab.com -browser
end

function y0=Newton(x,y,x0)
n=length(x);
A=zeros(n);
A(:,1)=y';
for j=2:n
    for i=1:(n-j+1)
        A(i,j)=(A(i+1,j-1)-A(i,j-1))/(x(i+j-1)-x(i));
    end
end

N(1)=A(1,1);
for j=2:n
    T=1;
    for i=1:j-1
        T=T*(x0-x(i));
    end
    N(j)=A(1,j)*T;
end
y0=sum(N);
end

TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

Open Toolbar