Code covered by the BSD License

# MATLAB Tools for Scientist

### Asawari Samant (view profile)

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

createFit_v1(x, y)
```function [fitresult, gof] = createFit_v1(x, y)
%CREATEFIT(X,Y)
%  Create a fit.
%
%  Data for 'untitled fit 1' fit:
%      X Input : x
%      Y Output: y
%  Output:
%      fitresult : a fit object representing the fit.
%      gof : structure with goodness-of fit info.
%

%  Auto-generated by MATLAB on 24-Oct-2012 22:23:15
% Copyright 2011 - 2012 MathWorks, Inc.

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

% Set up fittype and options.
ft = fittype( 'Emax*Dose^n/(Dose^n+EC50^n)', 'independent', 'Dose', 'dependent', 'y' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.Lower = [0 0 0 ];
opts.StartPoint = [10 10 10];
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' );
gcf ;  hold on ;
h = plot( fitresult, xData, yData );
legend( h, 'y vs. x', 'untitled fit 1', 'Location', 'NorthEast' );

% Create plot
set(h(1), 'MarkerFaceColor',[0 0 1],'MarkerEdgeColor',[0 0 1],...
'Marker','square',...
'LineStyle','none');

% Create xlabel
xlabel('Dose (mg)','FontSize',14,'FontName','Calibri');

% Create ylabel
ylabel('Response','FontSize',14,'FontName','Calibri');

% Create title
title({'Dose-Response Profile',''},'FontWeight','bold','FontSize',14,...
'FontName','Calibri');

set(gcf, 'color', 'w')
box on
drawnow```