Code covered by the BSD License  

Highlights from
Mathematical Modeling with MATLAB Products - webinar demo files

image thumbnail

Mathematical Modeling with MATLAB Products - webinar demo files

by

 

Demo files from March 10, 2011 webinar titled 'Mathematical Modeling with MATLAB Products'

createSurfaceFit(opioid, sedative, tetany)
function [fitresult, gof] = createSurfaceFit(opioid, sedative, tetany)
%CREATESURFACEFIT(OPIOID,SEDATIVE,TETANY)
%  Fit surface to data.
%
%  Data for 'custom equation' fit:
%      X Input : opioid
%      Y Input : sedative
%      Z Output: tetany
%  Output:
%      fitresult : an sfit object representing the fit.
%      gof : structure with goodness-of fit info.
%
%  See also FIT, SFIT.

%  Auto-generated by MATLAB on 08-Mar-2011 12:35:10
%  Copyright 2011 The MathWorks, Inc.


%% Fit: 'custom equation'.
[xInput, yInput, zOutput] = prepareSurfaceData( opioid, sedative, tetany );

% Set up fittype and options.
ft = fittype( 'combinedEffect(x, y, IC50A, IC50B, alpha, n)', 'indep', {'x', 'y'}, 'depend', 'z' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.Lower = [0 0 0 0];
opts.StartPoint = [0.701688166373293 0.933334221658604 0.471157664449075 0.491058789314676];
opts.Upper = [Inf Inf Inf Inf];

% Fit model to data.
[fitresult, gof] = fit( [xInput, yInput], zOutput, ft, opts );

% Plot fit with data.
figure( 'Name', 'custom equation' );
plot( fitresult, [xInput, yInput], zOutput );
% Label axes
xlabel( 'opioid' );
ylabel( 'sedative' );
zlabel( 'tetany' );
grid on


Contact us