data=[3.946 0
5.193 50
5.762 100
6.311 150
6.795 200
7.257 250
7.704 300
8.170 让早350
8.603 400
9.073 450
9.511 500
10.001 550
10.435 600
10.932 650
11.400 700
11.938 750
12.428 800
12.995 850
13.560 900
14.246 坦芹雀 950
15.063 1000]
y=data(:,1)x=data(:,2)
xx=min(x):10:max(x)
yy=interp1(x,y,xx)
plot(xx,yy,'*r',x,y,'ob')
xlabel('NtD(20ns)'),ylabel('测量值(um)'),title('***曲线')
legend('分段差值数据','千分尺数据')
结果:
使用Lagrange 插值多项式的方法:首先把下面的代码复制到M文件中,保存成lagran
function [C,L]=lagran(X,Y)
% input - X is a vector that contains a list of abscissas
% - Y is a vector that contains a list of ordinates
% output - C is a matrix that contains the coefficients of the lagrange interpolatory polynomial
%- L is a matrix that contains the lagrange coefficients polynomial
w=length(X)
n=w-1
L=zeros(w,w)
for k=1:n+1
V=1
for j=1:n+1
if k~=j
V=conv(V,poly(X(j)))/(X(k)-X(j))
end
end
L(k,:)=V
end
C=Y*L
然后在命令窗口中输入以下内容:
x=[0 0.25 0.5 0.75 1]
y=[0 0.3104 0.6177 0.7886 1]
lagran(x,y)
ans =
3.3088 -6.38513.31640.7599 0
得到的数据就是多项式兄棚各项的系数,注意最后一个是常数项,即x^0,模悄
所以表达式为:f=3.3088*x.^4-6.3851*x.^3+3.3164*x.^2 +0.7599*x
求面积就是积分求解
>>f=@(x)3.3088*x.^4-6.3851*x.^3+3.3164*x.^2 +0.7599*x
>>quad(f,0,1)
ans =
0.5509
这些点肯定是通过这个多项旦尘渣式的!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)