1 对原数据插值+平滑
x y 原数据
xi yi 处理后数据
xi=0.002:1/2000:1yi= interp1(x,y,xi,'spline')semilogx(xi,yi)
2 知y求x
思想:把x和y反过来
%S是y,T是xplot(S(1,:),T)y1=0:0.1:100x1=interp1(S(1,:),T,y1)plot(S(2,:),T)y2=0:0.1:100x2=interp1(S(2,:),T,y2)plot(S(3,:),T)y3=0:0.1:100x3=interp1(S(3,:),T,y3)plot(S(4,:),T)y4=0:0.1:100x4=interp1(S(4,:),T,y4)plot(S(5,:),T)y5=0:0.1:100x5=interp1(S(5,:),T,y5)plot(S(6,:),T)y6=0:0.1:100x6=interp1(S(6,:),T,y6)plot(S(7,:),T)y7=0:0.1:100x7=interp1(S(7,:),T,y7)plot(S(8,:),T)y8=0:0.1:100x8=interp1(S(8,:),T,y8)f=[x1;xt;x3;x4;x5;x6;x7;x8]%找到D25\D50\D75对应的值L=f(:,251)K=f(:,501)J=f(:,751)
3 读取拟合曲线点坐标
不需要插值也可以
plot(D,D)p(1)=spline(D,D)t=[0.02]Y1=ppval(p(1),t)
当x=0.02时,得到对应的y值
也可以批量求,yi是很多年份的集合
plot(xi,yi)p(1)=spline(xi,yi)t=[0.02]Y1=ppval(p(1),t)
%从excel导入X和Y(X级配分类,Y级配百分比)xx = 0:0.5:128; %xx是设定的新插值点% interp1对sin函数进行分段线性插值,调用interp1的时候,默认的是分段线性插值 y1 = interp1(X,Y,xx,'linear'); plot(X,Y,'o',xx,y1,'r') ``title('分段线性插值')