|
- General model Exp2:
- f(x) = a*exp(b*x) + c*exp(d*x)
- Coefficients (with 95% confidence bounds):
- a = 0.1916 (0.1792, 0.204)
- b = -0.319 (-0.3373, -0.3006)
- c = 0.04072 (0.03814, 0.04329)
- d = -0.04487 (-0.0476, -0.04214)
- Goodness of fit:
- SSE: 1.669e-006
- R-square: 0.9997
- Adjusted R-square: 0.9997
- RMSE: 0.0002754
复制代码
- function createFit(x,y)
- %CREATEFIT Create plot of data sets and fits
- % CREATEFIT(X,Y)
- % Creates a plot, similar to the plot in the main Curve Fitting Tool,
- % using the data that you provide as input. You can
- % use this function with the same data you used with CFTOOL
- % or with different data. You may want to edit the function to
- % customize the code and this help message.
- %
- % Number of data sets: 1
- % Number of fits: 1% Data from data set "y vs. x":
- % X = x:
- % Y = y:
- % Unweighted% Auto-generated by MATLAB on 18-Apr-2011 10:56:55% Set up figure to receive data sets and fits
- f_ = clf;
- figure(f_);
- set(f_,'Units','Pixels','Position',[578 254 688 485]);
- % Line handles and text for the legend.
- legh_ = [];
- legt_ = {};
- % Limits of the x-axis.
- xlim_ = [Inf -Inf];
- % Axes for the plot.
- ax_ = axes;
- set(ax_,'Units','normalized','OuterPosition',[0 0 1 1]);
- set(ax_,'Box','on');
- axes(ax_);
- hold on;% --- Plot data that was originally in data set "y vs. x"
- x = x(:);
- y = y(:);
- h_ = line(x,y,'Parent',ax_,'Color',[0.333333 0 0.666667],...
- 'LineStyle','none', 'LineWidth',1,...
- 'Marker','.', 'MarkerSize',12);
- xlim_(1) = min(xlim_(1),min(x));
- xlim_(2) = max(xlim_(2),max(x));
- legh_(end+1) = h_;
- legt_{end+1} = 'y vs. x';% Nudge axis limits beyond data limits
- if all(isfinite(xlim_))
- xlim_ = xlim_ + [-1 1] * 0.01 * diff(xlim_);
- set(ax_,'XLim',xlim_)
- else
- set(ax_, 'XLim',[4.75, 30.25]);
- end% --- Create fit "fit 1"
- ok_ = isfinite(x) & isfinite(y);
- if ~all( ok_ )
- warning( 'GenerateMFile:IgnoringNansAndInfs',...
- 'Ignoring NaNs and Infs in data.' );
- end
- st_ = [0.15243570612980811 -0.25709456653830987 0.033745642790019854 -0.038489626682204618 ];
- ft_ = fittype('exp2');% Fit this model using new data
- cf_ = fit(x(ok_),y(ok_),ft_,'Startpoint',st_);
- % Alternatively uncomment the following lines to use coefficients from the
- % original fit. You can use this choice to plot the original fit against new
- % data.
- % cv_ = { 0.19159877789258178, -0.31895949786907274, 0.040716429909295873, -0.044867078417144955};
- % cf_ = cfit(ft_,cv_{:});% Plot this fit
- h_ = plot(cf_,'fit',0.95);
- set(h_(1),'Color',[1 0 0],...
- 'LineStyle','-', 'LineWidth',2,...
- 'Marker','none', 'MarkerSize',6);
- % Turn off legend created by plot method.
- legend off;
- % Store line handle and fit name for legend.
- legh_(end+1) = h_(1);
- legt_{end+1} = 'fit 1';% --- Finished fitting and plotting data. Clean up.
- hold off;
- % Display legend
- leginfo_ = {'Orientation', 'vertical', 'Location', 'NorthEast'};
- h_ = legend(ax_,legh_,legt_,leginfo_{:});
- set(h_,'Interpreter','none');
- % Remove labels from x- and y-axes.
- xlabel(ax_,'');
- ylabel(ax_,'');
-
复制代码
|
评分
-
1
查看全部评分
-
|