>> model % display model informations
>> model('identify') % idem
>> model('plot') % plot the model with its default settings
>> model(p, x, y ...) % evaluate the model with parameters p, and axes x,y,...
>> model([], x, y ...) % evaluate the model with axes x,y,... and automatic parameter guess
>> model('guess', x, y ...) % idem
>> ieval(a, @model, p) % evaluate the model onto the iData object axes with parameters p
>> fits(a, @model, p) % fit the model onto the iData object
Function |
Description |
Dimensionality |
Parameters |
allometric |
Allometric (power/asymptotic law) |
1D |
Amplitude Offset Exponent BackGround |
bigauss |
Asymmetric Gaussian |
1D | Amplitude Centre HalfWidth1 HalfWidth2 Background |
bilorz |
Asymmetric Lorentzian |
1D | Amplitude Centre HalfWidth1 HalfWidth2 Background |
bose | Bose factor |
1D | Tau [h/2pi/kT] in "x" units |
dho |
Damped harmonic oscillator |
1D | Amplitude Centre HalfWidth
Background Temperature (in "x" unit) |
dirac |
Dirac peak |
1D |
Amplitude Centre |
doseresp |
Dose-response curve with variable Hill slope. This is a sigmoid or S-shaped. |
1D |
Amplitude Center Slope BackGround |
expon |
Exponential decay |
1D |
Amplitude Tau Background |
expstretched |
Exponential - Stretched |
1D |
Amplitude Tau Exponent Background |
gauss | Gaussian |
1D | Amplitude Centre HalfWidth
Background |
green |
Green function |
1D |
Amplitude Centre HalfWidth Background |
heaviside |
Heaviside (gap) The GapSide indicates raising (+) or falling (-) gap. |
1D |
Amplitude Centre GapSide Background |
langevin |
Langevin function for magnetic polarization |
1D |
Amplitude Center Width BackGround |
laplace |
Laplace distribution function |
1D |
Amplitude Center Width BackGround |
lognormal |
Log-Normal distribution |
1D |
Amplitude Center Width BackGround |
lorz |
Lorentzian |
1D | Amplitude Centre HalfWidth Background |
pareto |
Pareto distribution function |
1D |
Amplitude Exponent Width BackGround |
poisson |
Poisson distribution WARNING: The 'x' axis is assumed to be an integer array (counts) |
1D |
Amplitude Center BackGround |
pseudovoigt |
Pseudo Voigt |
1D |
Amplitude Center Width BackGround LorentzianRatio |
quadline |
Quadratic line (parabola) |
1D |
Quadratic Linear Constant |
sigmoid |
Sigmoidal S-shaped curve (similar to Dose Response) |
1D | Amplitude Center Width BackGround |
sine |
Sine function |
1D |
Amplitude Phase_Shift Period BackGround |
sinedamp |
Damped Sine function (exponential decay) |
1D |
Amplitude Phase_Shift Period BackGround Decay |
strline |
Straight line |
1D |
Gradient
Background |
triangl |
Triangular |
1D | Amplitude Centre HalfWidth Background |
tophat |
Top-Hat rectangular function |
1D | Amplitude Centre HalfWidth Background |
twoexp |
Two exponential decay functions |
1D | Amplitude1 Tau1 Amplitude2 Tau2 Background |
voigt |
Voigt function |
1D |
Amplitude Centre HalfWidth_Gauss HalfWidth_Lorz Background |
gauss2d |
Gaussian function with tilt angle |
2D |
Amplitude Centre_X Center_Y HalfWidth_X HalfWidth_Y Angle Background |
lorz2d |
Lorentzian function with tilt angle | 2D | Amplitude Centre_X Center_Y HalfWidth_X HalfWidth_Y Angle Background |
plane2d |
Planar function |
2D | Slope_X Slope_Y Background |
pseudovoigt2d |
Pseudo Voigt with tilt angle | 2D | Amplitude Centre_X Center_Y HalfWidth_X HalfWidth_Y Angle Background LorentzianRatio |
quad2d |
Quadratic (parabola) with tilt angle | 2D | Amplitude Centre_X Center_Y Curvature_X Curvature_Y Angle Background |
>> fits(iData);which also prodices the plot above.
>> h=ifitmakefunc;The only required argument is the expression, but you may as well enter a function name and description, parameter names and default values, as well as a constraint to be evaluated before computing the function value. When started without any parameters, the Gaussian function settings are used.
>> [p,criteria,message,output]= fits(a, h);A quick definition, without using the dialog, can be performed with the syntax:
>> h=ifitmakefunc('p(1)*exp( (x-p(2))/p(3) )');where p is the vector that holds parameters. Axes are x (rows),y (columns),z (pages),t (time). The letter parameters a,b,c ... o can be used in place of p(1), p(2), ... Beware to use a model expression with element-wise division and multiplication operators (./ and .*). The function builder is known to work well for 1D and 2D functions.
>> fits(a, h);
>> h=ifitmakefunc('expression');which is equivalent to:
>> h=ifitmakefunc('expression', 'constraints');
>> h=ifitmakefunc('function_name', 'description', 'Parameter1 Parameter2 ...', ...
'expression', [default parameter values], 'constraint');
>> fun.function='function_name'; % function nameThe generated code will basically be:
>> fun.Description='function description'; % function long description
>> fun.Parameters='Parameter1 Parameter2 ...'; % parameter names. When empty, names are given according to the Expression analysis (when appropriate)
>> fun.Guess=[0 1 2 ...] or 'automatic'; % parameter default values (vector), or automatic mode
>> fun.Expression='expression using p and x,y,z,t...'; % value of the model (required). p is the vector that holds parameters. Axes are x,y,z,t.
>> fun.Constraint='evaluated before Expression'; % constraint evaluated prior to the model Expression
>> h=ifitmakefunc(fun);
>> fits(a, h);
function y=[fun.function](p, axes, ...)The resulting function has the ability to identify itself ('identify', provide detailed informations), compute automatic starting parameters ('guess'), display itself ('plot'), and evaluate its value of course. The resulting function embeds the automatic guess functionality (iFuncs_private_guess), and thus can be stored anywhere in the Matlab search path, but should better be in the iFit/iFuncs directory so that it appears in the fits(iData) function list.
% [fun.Description]
% Parameters: [fun.Parameters]
[fun.Constraint];
y=[fun.Expression];
>> h=ifitmakefunc('gausslorz', ...which creates a new function which is the sum of a Gaussian and a Lorentzian. The second redundant Lorentzian Background p(8) parameter is forced to 0 so that it does not correlate with the Gaussian Background p(4). The function has all the features listed above (plot/identify/guess).
'Gaussian+Lorentzian function', ...
'Amplitude1 Centre1 HalfWidth1 Background1 Amplitude2 Centre2 HalfWidth2 Background2', ...
'gauss(p(1:4),x)+lorz(p(5:8),x)', ...
'automatic', 'p(8)=0');
ifitmakefunc: Wrote function signal=gausslorz(p, x)
% Gaussian+Lorentzian function
% 8 parameter(s): 'Amplitude1' 'Centre1' 'HalfWidth1' 'Background1' 'Amplitude2' 'Centre2' 'HalfWidth2' 'Background2'
p(8)=0;
signal=gauss(p(1:4),x)+lorz(p(5:8),x);
Stored in: /home/farhi/gausslorz.m
>> h=ifitmakefunc('gauss(p(1:4),x)+lorz(p(5:8),x)', 'p(8)=0');where unspecified arguments are guessed/automatically set.
>> c = fconv(a,b); % returned convoluted object with size which is size(a)+size(b)+1When some data has to be convoluted with a response function (e.g. instrument resolution function), the usual options to use should be:
>> c = fconv(a,b, 'same'); % returned convoluted object with size which is size(a)
>> c = fconv(a,b, 'valid'); % returned convoluted object with size which is size(a)-size(b)+1
>> c = fconv(a,b, 'pad'); % pads 'a' with starting/ending values to minimize border effects
>> c = fconv(a,b, 'center'); % centers 'b' so that convolution does not shift 'a'
>> c = fconv(a,b, 'norm'); % normalizes 'b' so that convolution does not change 'a' integral
>> c = fconv(a,b, 'background');% subtracts minimal value in 'b' so that convolution does not change 'a' integral
>> c = fconv(a,b, 'deconv'); % deconvolution, but very sensitive to noise (use with caution)
>> c = fconv(a,b, 'same pad background center norm');Using fconvn, we may assemble a new function as:
>> c = fconvn(a,b); % same as above in a shorter call
>> global b; % holds the convolution function as a single vector/matrix or iData objectwhere the vector/matrix 'b' holds the response function (filter) with the same axis binning as the object 'a'.
>> h = ifitmakefunc('fconvn(gauss(p(1:4),x), double(b))','global b'); % creates a fit function with convolution
>> h = ifitmakefunc('fconvn(lorz(p(1:4),x)+dho(p(5:9),x), gauss(p(10:13),x))');which in this example as a Lorentizian plus a DHO convolved with a Gaussian. In order for iFit to be able to guess starting parameters, you may need to specify manually the parameter names for that function, such as in:
>> h = ifitmakefunc('conv_lorzdho_gauss', ... % name of the functionInstead of the convolution, the correlation can also be computed using the function fxcorr similarly as fconv.
'conv(Lorz+DHO, Gauss)', ... % description
[ 'Lorz_Amplitude Lorz_Centre Lorz_HalfWidth Lorz_Background ' ... % Parameter names
'DHO_Amplitude DHO_Centre DHO_HalfWidth DHO_Background DHO_Temperature ' ...
'Gauss_Amplitude Gauss_Centre Gauss_HalfWidth Gauss_Background' ], ...
'fconvn(lorz(p(1:4),x)+dho(p(5:9),x), gauss(p(10:13),x))'); % expression
>> h = ifitmakefunc('fconvn(lorz(p(1:4),xx)+dho(p(5:9),xx), gauss(p(10:13),xx)); signal=signal(1:5:end);', ...
'xx=linspace(min(x),max(x), 5*length(x));');