📄 decaycurvefit.m
字号:
function decaycurvefit(x,y1,y2)%DECAYCURVEFIT Create plot of datasets and fits% DECAYCURVEFIT(X,Y1,Y2)% Creates a plot, similar to the plot in the main curve fitting% window, using the data that you provide as input. You can% apply this function to 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 datasets: 2% Number of fits: 2 % Data from dataset "Left Mic":% X = x:% Y = y1:% Unweighted % Data from dataset "Right Mic":% X = x:% Y = y2:% Unweighted%% This function was automatically generated% Set up figure to receive datasets and fitsf_ = clf;figure(f_);legh_ = []; legt_ = {}; % handles and text for legendxlim_ = [Inf -Inf]; % limits of x axisax_ = subplot(1,1,1);set(ax_,'Box','on');axes(ax_); hold on; % --- Plot data originally in dataset "Left Mic"x = x(:);y1 = y1(:);h_ = line(x,y1,'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} = 'Left Mic'; % --- Plot data originally in dataset "Right Mic"y2 = y2(:);h_ = line(x,y2,'Parent',ax_,'Color',[0.333333 0.666667 0],... '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} = 'Right Mic';% --- Create fit "1/r Decay"st_ = [0.9501292851472 0.2311385135743 ];ft_ = fittype('rat01' );% Fit this model using new datacf_ = fit(x,y2,ft_ ,'Startpoint',st_);% Or use coefficients from the original fit:if 0 cv_ = {0.004566294359658, 0.121198959794}; cf_ = cfit(ft_,cv_{:});endh_ = plot(cf_,'fit',0.95);legend off; % turn off legend from plot method callset(h_(1),'Color',[1 0 0],... 'LineStyle','-', 'LineWidth',2,... 'Marker','none', 'MarkerSize',6);legh_(end+1) = h_(1);legt_{end+1} = '1/r Decay';% --- Create fit "1/r Decay Left"st_ = [0.9501292851472 0.2311385135743 ];ft_ = fittype('rat01' );% Fit this model using new datacf_ = fit(x,y1,ft_ ,'Startpoint',st_);% Or use coefficients from the original fit:if 0 cv_ = {0.006838021722671, 0.2221929378311}; cf_ = cfit(ft_,cv_{:});endh_ = plot(cf_,'fit',0.95);legend off; % turn off legend from plot method callset(h_(1),'Color',[0 0 1],... 'LineStyle','-', 'LineWidth',2,... 'Marker','none', 'MarkerSize',6);legh_(end+1) = h_(1);legt_{end+1} = '1/r Decay Left';hold off;legend(ax_,legh_, legt_);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -