Code covered by the BSD License  

Highlights from
MATLAB Tools for Scientist

image thumbnail

MATLAB Tools for Scientist

by

 

Files from the webinar: MATLAB Tools for Scientists- Introduction to Data Analysis and Visualization

createFit(iDose, iResponse)
function [fitresult, gof] = createFit(iDose, iResponse)
%CREATEFIT(IDOSE,IRESPONSE)
%  Create a fit.
%
%  Data for 'untitled fit 1' fit:
%      X Input : iDose
%      Y Output: iResponse
%  Output:
%      fitresult : a fit object representing the fit.
%      gof : structure with goodness-of fit info.
%
%  See also FIT, CFIT, SFIT.

%  Auto-generated by MATLAB on 13-Nov-2012 15:58:25
% Copyright 2011 - 2012 MathWorks, Inc.

%% Fit: 'untitled fit 1'.
[xData, yData] = prepareCurveData( iDose, iResponse );

% Set up fittype and options.
ft = fittype( 'Emax*dose^n/(dose^n + EC50^n)', 'independent', 'dose', 'dependent', 'R' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.Lower = [0 0 0];
opts.StartPoint = [0.638530758271838 0.0336038360664295 0.0688060991180512];
opts.Upper = [Inf Inf Inf];

% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );

% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, xData, yData );
legend( h, 'iResponse vs. iDose', 'untitled fit 1', 'Location', 'NorthEast' );
% Label axes
xlabel( 'iDose' );
ylabel( 'iResponse' );
grid on


Contact us