-
Notifications
You must be signed in to change notification settings - Fork 1
/
LeviAlgorithm.m
47 lines (33 loc) · 910 Bytes
/
LeviAlgorithm.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
function [Model] = LeviAlgorithm(G,w,nb,na, varargin)
p = inputParser;
% Create variable names and assign default values after checking the value
addRequired(p,'G', @isnumeric);
addRequired(p,'w', @isnumeric);
addRequired(p,'nb', @isnumeric);
addRequired(p,'na', @isnumeric);
% Optional parameteres
addParameter(p,'domain','s');
addParameter(p,'fs',1);
% Re-parse parObj
parse(p,G,w,nb,na,varargin{:})
G = p.Results.G;
w = p.Results.w;
nb = p.Results.nb;
na = p.Results.na;
fs = p.Results.fs;
if p.Results.domain == 's'
v = 1i*w*fs;
else
v = exp(-1i*w);
end
F = length(w);
%Construct regressor matrix
for kk = 1:F
Reg(kk,:) = [-G(kk)*(v(kk).^(na:-1:1)) v(kk).^(nb:-1:0)];
end
Regt = [real(Reg);imag(Reg)];
Gt = [real(G);imag(G)];
[theta, results] = Lls(Regt,Gt);
Model.A = theta(1:na);
Model.B = theta(na+1:end);
Model.results = results;