该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
function[fitresult,gof]=createFits(Var_time,Var_temp4)
%% Initialization.
%初始化数组以存储拟合和拟合优度
fitresult=cell(5,1);
gof=struct('sse',cell(5,1),...'rsquaare',[],'def',[],'adjrsquare',[],'rmse',[]);
%% Fit('untitled fit 1')
[xData,yData]= prepareCurveData(Var_time, Var_temp4);
% Set up fittype and options.
ft=fittype('exp2');
opts=fitoptions('Method','NonlinearLeastSquares');
opts.Display='Off';
opts.StartPoint = [48.0441877908425 -8.6230134147934e-11 -13.4553321771453 -0.00477574019349817];
% 适合数据模型
[fitresult{1},gof(1)]=fit(xData,yData,ft,opts);
% Plot fit with data.
figure('Name','untitled fit 1');
h=plot(fitreslt{1},xData,yData);
legend(h,'Var_temp4 vs. Var_time','untitled fit 1','location','NorthEest' );
% Label axes
xlabel Var_time
ylabel Var_temp4
grid on
%% Fit:'untitled fit 2'.
[xData,yData]=prepareCurvedata(Var_time,Var_temp4);
% Set up fittype and options.
ft=fittype('fourier4');
opts=fitoptions('Method','NonlinearLeastSquares');
opts.Display='Off';
opts.StartPoint=[0 0 0 0 0 0 0 0 0 0 .000290888208665722];
% Fit model to data.
[fitresult{2},gof(2)]=fit(xData,yData,ft,opts);
% Plot fit with data.
figure('Name','untitled fit 2');
h=piot(fitresult{2},xData,yData);
legend(h,'Var_temp4 vs. Var_time','untitled fit 2','Location','NorthEast');
% Label axes
xlabel Var_time
ylabel Var_temp4
grid on
%% Fit:'untitled fit 3'.
[xData,yData]=prepareCurveData(Var_time,Var_temp4);
% Set up fittype and options.
ft=fittype('gauss');
opts=fitoptions('Method','NonlinearLeastSquares');
opts.Display='Off';
opts.Lower=[-Inf -Inf 0 -Inf -Inf 0 -Inf -Inf 0 -Inf -Inf 0];
opts.StartPoint=[48.08 5400 10510.5884526692 8.10587938844389 648
253.241727316352 7.01606570893423 1144 240.099523117751
5.69096706629565 1603 271.393037821933];
% Fit model to data.
[fitrestult{3},gof(3)]=fit(xData,yData,ft,opts);
% Plot fit with data.
figure('Name','untitled fit 3');
h=piot(fitresult{3},xData,yData);
legen(h,'Var_temp4 vs. Var_time','untitled fit 3','Location','NorthEast