-
Notifications
You must be signed in to change notification settings - Fork 1
/
model.m
83 lines (75 loc) · 1.9 KB
/
model.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
function [yModel,yErf,yBaseline]=model(obj,varargin)
%% Create Fit Model Using the Fit Results
% [yModel,yPeak,yBaseline]=obj.model() returns a set of fit models evaluated at
% the data points.
%
% [yModel,yPeak,yBaseline]=obj.model(x) evaluates the fit models at x instead.
%
% [yModel,yPeak,yBaseline]=obj.model(x_?,x_?) evaluates the fit models for
% curve ? at x_? and curve ? at x_?.
%
% Outputs:
% yModel: The reconstructed data points from the fit results.
%
% yPeak: A cell containing the resconstructed data points of each peak.
%
% yBaseline: The reconstructed baseline points.
%
% Requires package:
% - Common_v1.0.0+
%
% Tested on:
% - MATLAB R2013b
% - MATLAB R2015b
%
% Copyright: Herianto Lim
% http://heriantolim.com/
% First created: 29/05/2013
% Last modified: 25/10/2016
yModel=cell(1,2);
yErf=cell(1,2);
yBaseline=cell(1,2);
center=obj.Center;
height=obj.Height;
width=obj.Width;
baseline=obj.Baseline;
if isempty(center) || isempty(height) || isempty(width) || isempty(baseline)
return
end
%% Parse Inputs
if nargin==1
xModel=obj.XData;
elseif nargin>2
error('BiErfFit:model:TooManyInput',...
'At most one input argument is accepted.');
elseif isrealvector(varargin{1})
xModel=repmat(varargin(1),1,2);
elseif iscell(varargin{1}) && numel(varargin{1})==2 ...
&& isrealvector(varargin{1}{1}) && isrealvector(varargin{1}{2})
xModel=varargin{1};
else
error('BiErfFit:model:InvalidInput',...
['Input to the domains for the model must be either a real vector ',...
'or a cell containing two real vectors.']);
end
%% Construct Baseline
for i=1:2
yBaseline{i}=baseline(1,1)*ones(size(xModel{i}));
end
%% Construct Erf
N=obj.NumErfs;
for i=1:2
yErf{i}=cell(1,N(i));
for j=1:N(i)
yErf{i}{j}=BiErfFit.fnerf(xModel{i},...
center{i}(1,j),height{i}(1,j),width{i}(1,j));
end
end
%% Construct Model
for i=1:2
yModel{i}=yBaseline{i};
for j=1:N(i)
yModel{i}=yModel{i}+yErf{i}{j};
end
end
end