-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPROJECT_FUNCTION_LIBRARY.txt
191 lines (105 loc) · 5.69 KB
/
PROJECT_FUNCTION_LIBRARY.txt
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
Library of M-files desiged for main programs: Phase{1,2,3,4,5} and for future
work in filter design
FUNCTION: cardinalSinShifted
CALL: hn = cardinalSinShifted(M, wc, Ts)
Evaluates the sampled version of a continous sinc in M
points with the sampling period Ts
%-----------------------------------------------------------------------------%
FUNCTION: changePhaseToLinear
CALL: [H_new, b, a] = changePhaseToLinear(b, a)
Takes in filter coefficients for any given filter and returns
the coefficients of a filter with linear pahse and the same
spectruum
%-----------------------------------------------------------------------------%
FUNCTION: checkError
CALL: check = checkError(deltaP, deltaP_max, deltaS, deltaS_max)
Checks if deltaP < deltaP_max and deltaS < deltaS_max, and returns
1 if the conditions hold
%-----------------------------------------------------------------------------%
FUNCTION: checkType
CALL: check = checkType(type, indx)
Checks if a given window it's in one of the specified sets, indx must be
a vector with values in range 1 to 9. Returns 1 if the window given by
the parameter type it's one from the values at indx
%-----------------------------------------------------------------------------%
FUNCTION: filterDesign
CALL: [b, a, filterOrder, deltaP_real, deltaS_real, error, found] =....
filterDesign(Fp, Fs, deltaP, deltaS, Ts, Wn, wn_param, M, type)
Returns the impulse response of the best filter with passband frequency Fp
and stopband frequency Fs, with sampling period Ts with order less than M
and which respects the passband deltaP and stopband deltaS constraints for
a given window
%-----------------------------------------------------------------------------%
FUNCTION: FIR
CALL: [b, a] = FIR(order, wc, Ts, window, type)
The functions returns a FIR filter of type type and of order order and cutoff
frequency wc with sampling period Ts using the window given by the vector window
%-----------------------------------------------------------------------------%
FUNCTION: getWindow
CALL: Wn = getWindow(Wn, order, wn_param)
Returns a window of type Wn of length order
DEFAULT: hanning window of length 16
%-----------------------------------------------------------------------------%
FUNCTION: getWindowName
CALL: [w, titles] = getWindowName()
Returns the standard window names and titles for frequency response
%-----------------------------------------------------------------------------%
FUNCTION: lanczos
CALL: h = lanczos(M, L)
Returns the values of a lanczos window of length M using the extra
parameter L
%-----------------------------------------------------------------------------%
FUNCTION: plotFilterDesign
CALL: [deltaP_real, deltaS_real, error] =....
plotFilterDesign(Fp, Fs, deltaP, deltaS, Ts, Wn, wn_param, M, plots)
Plots the impulse response of the best filter with passband frequency Fp
and stopband frequency Fs, with sampling period Ts with order less than M
and which respects the passband deltaP and stopband deltaS constraints for
a given window
%-----------------------------------------------------------------------------%
FUNCTION plotGain
CALL: [] = plotGain(H, omeg, titleNormalScale)
Plots the frequency response of a filter on the scale omeg with title
given by titleNormalScale
%-----------------------------------------------------------------------------%
FUNCTION plotGainDB
CALL: [] = plotGainDB(H, omeg, titleDBScale)
Plots the frequency response in dB of a filter on the scale omeg with title
given by titleDBScale
%-----------------------------------------------------------------------------%
FUNCTION plotPhase
CALL: [] = plotPhase(H, omeg, titlePhase)
Plots the frequency response phase of a filter on the scale omeg with title
given by titlePhase
%-----------------------------------------------------------------------------%
FUNCTION: plotWindowFIRResponse
CALL: [] = plotWindowFIRResponse(w, titles, order, wc, Ts, wn_param)
Plots the frequency response of the specified windows, with cutoff
frequency wc, samplit period Ts and using the parameters in wn_param for
the windows.
SUPPORTS ONLY LOW-PASS FILTER AT THE MOMENT !
%-----------------------------------------------------------------------------%
FUNCTION: rankFilters
CALL: [rankingFilters, tableRank, error] =....
rankFilters(Fp, Fs, deltaP, deltaS, Ts, Wn, wn_param, M, type)
Returns the best filters with passband frequency Fp and stopband frequency Fs,
with sampling period Ts with order less than M and which respects the passband
deltaP and stopband deltaS constraints for a all 9 windows
%-----------------------------------------------------------------------------%
FUNCTION: returnMaxError
CALL: [deltaP_max, deltaS_max] = returnMaxError(H, w, wp, ws, type)
Returns the maximum passband error and the maximum stopband error
for a given filter
%-----------------------------------------------------------------------------%
FUNCTION: setDefaultParamsForAllWindows
CALL: wn_param = setDefaultParamsForAllWindows(Wn)
Returns the default parameters for all windows
%-----------------------------------------------------------------------------%
FUNCTION: setParamFor
CALL: wn_param = setParamFor(Wn)
Returns the default parameters for the given window
%-----------------------------------------------------------------------------%
FUNCTION: truncateCellArray
CALL: truncatedCellArray = truncateCellArray(cellArray, new_size)
The functions truncate the input cell array to the new_size, if no new
size is given the output cell array has the same length as the input