%多项式曲线拟合
figure(1)
matrix2=[]; %新建空矩阵
h1=polyfit(matrix1(:,1),matrix1(:,2),3); %计算多项式拟合系数,3-拟合次数
matrix2(:,1)=polyval(h1,matrix1(:,1),1); %计算拟合函数值y
plot(matrix1(:,1),matrix2(:,1)) %绘制拟合曲线
title(‘Predicred realations between noncoaxiality and bedding angle’); %标题
set(gca,‘FontName’,‘Time New Roman’,‘fontsize’,12) %字体
%legend(’\rho-\theta’) %图例
xlabel(‘Bedding angle \theta[^\o]’) %x坐标名称
ylabel(‘Angle of noncoaxiality \rho[^\o]’) %y坐标名称
xlim([0,90]) %限制x坐标绘图范围
ylim([0,5]) %限制y坐标绘图范围
set(gca,‘XTick’,(0:10:90)) %设置x坐标间隔
set(gca,‘YTick’,(0:1:5)) %设置y坐标间隔
%样条曲线拟合
figure(2)
values = spcrv([[matrix1(1,1)’ matrix1(:,1)’ matrix1(end,1)’]; [matrix1(1,2)’ matrix1(:,2)’ matrix1(end,2)’]],3); %三次样条曲线拟合
plot(values(1,:),values(2,:), ‘b’); %绘制曲线
title(‘Predicred realations between noncoaxiality and bedding angle’);
set(gca,‘FontName’,‘Time New Roman’,‘fontsize’,12)
xlabel(‘Bedding angle \theta[^\o]’)
ylabel(‘Angle of noncoaxiality \rho[^\o]’)
xlim([0,90])
ylim([0,5])
set(gca,‘XTick’,(0:10:90))
set(gca,‘YTick’,(0:1:5))