Code covered by the BSD License  

Highlights from
Response Surface Models of Drug Interactions with Curve Fitting Toolbox

image thumbnail
from Response Surface Models of Drug Interactions with Curve Fitting Toolbox by Asawari Samant
"Response Surface Models of Drug Interactions with Curve Fitting Toolbox" webinar demo files

myCreateSurfaceFit(Propofol, Remifentanil, Effect, EffectName)
function [fitresult, gof] = myCreateSurfaceFit(Propofol, Remifentanil, Effect, EffectName)
%CREATESURFACEFIT2(PROPOFOL,REMIFENTANIL,Effect)
%  Fit surface to data.
%
%  Data for 'Model' fit:
%      X Input : Propofol
%      Y Input : Remifentanil
%      Z output: Effect
%      Weights : (none)
%
%  Output:
%      fitresult : an sfit object representing the fit.
%      gof : structure with goodness-of fit info.
%
%  See also FIT, SFIT.

%  Auto-generated by MATLAB on 16-Mar-2009 13:34:42

% Initialize arrays to store fits and goodness-of-fit.
% Copyright 2009, The MathWorks, Inc.

fitresult = cell( 1, 1 );
gof = struct( 'sse', cell( 1, 1 ), ...
    'rsquare', [], 'dfe', [], 'adjrsquare', [], 'rmse', [] );

%% Fit: 'Model'.
ft = fittype( 'combinedEffect(x,y, IC50A, IC50B, alpha, n)', 'indep', {'x', 'y'}, 'depend', 'z' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.Lower = [0 0 -5 -0];
opts.Robust = 'LAR';
opts.StartPoint = [0.00893838724332152 0.706165672266879 1 0.746030748284422];
opts.Upper = [Inf Inf Inf Inf];
opts.Weights = zeros(1,0);
[fitresult{1}, gof(1)] = fit( [Propofol, Remifentanil], Effect, ft, opts ) ; 

% Create a figure for the plots.
f = figure( 'Name', 'Model', 'Color', [1 1 1]);

% Plot fit with data.
subplot1 = subplot( 2, 1, 1 );
h = plot( fitresult{1}, [Propofol, Remifentanil], Effect );
grid on
view(subplot1 , [-60 20]);
% Label axes
xlabel( 'Propofol' );
ylabel( 'Remifentanil' );
zlabel( EffectName );
% legend( h, 'Model Fit', 'Data', 'Location', 'NorthEast' );
set(h(1), 'FaceColor',[0.702 0.7804 1],...
          'FaceAlpha',0.6,...
          'EdgeAlpha',0.5);
      
set(h(2), 'MarkerFaceColor',[0, 0 ,1],...
          'MarkerEdgeColor',[0 0 1]  ,...
          'MarkerSize'     , 5);
       

% Plot residuals.
subplot2 = subplot( 2, 1, 2 );
h = plot( fitresult{1}, [Propofol, Remifentanil], Effect, 'Style', 'Residual' );
grid on
view(subplot2,[-60 20]);
% Label axes
xlabel( 'Propofol' );
ylabel( 'Remifentanil' );
zlabel( ['Residuals ', EffectName] );
% legend( h, 'Model - residuals', 'Location', 'NorthEast' );

set(h, 'MarkerFaceColor',[0, 0 ,1],...
        'MarkerEdgeColor',[0 0 1]  ,...
        'MarkerSize'     , 5);
      

Contact us