clear;clc
a=xlsread('预测广义可加变形抗力.xlsx');
y0=a(:,15);x=a(:,16:18);%准备原始数据，x0第1,2,3列代表x1,x2,x3
Pos=[0 0 0 0];%拟合参数的初始值任意选取
%lb=[0 0 0 0 -26000000000];%参数下界
%ub=[2 2 2 2 -22000000000];%参数上界
canshu=lsqcurvefit(@fun1,Pos,x,y0); %调用命令
yp=fun1(canshu,x);%计算拟合值
plot(1:length(y0),y0,'r-*',1:length(yp),yp,'b-o' ,'LineWidth', 1);
legend('真实值','预测值')
xlabel('预测样本')
ylabel('预测结果')
xlim([1, length(y0)])
RSS=sum((yp-y0).^2);%计算残差平方和
MAPE = mean(abs((yp - y0)./y0));
R2 = 1 - norm(yp -  y0)^2 / norm(y0 -  mean(y0 ))^2;
disp('拟合后的系数矩阵为:');
disp(canshu);
disp('残差平方和为：');
disp(RSS);
disp('平均绝对误差为：');
disp(MAPE);
disp('回归系数');
disp(R2);