-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathfhanning.m
More file actions
42 lines (37 loc) · 762 Bytes
/
fhanning.m
File metadata and controls
42 lines (37 loc) · 762 Bytes
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
function [w,wl,wr]=fhanning(n)
% [w,wl,wr]=fhanning(n)
%
% Calculates Hanning windows of a certain length
%
% INPUT:
%
% n The required length of the window
%
% OUTPUT:
%
% w The Hanning window for bandpass
% wl The left half of the window for lowpass
% wr The right half of the window for lowpass
%
% SEE ALSO:
%
% SHANNING
%
% Last modified by fjsimons-at-alum.mit.edu, 08/18/2021
if ~rem(n,2)
% Even length window
half = n/2;
wl = channing(half,n);
w = [wl; wl(end:-1:1)];
else
% Odd length window
half = (n+1)/2;
wl = channing(half,n);
w = [wl; wl(end-1:-1:1)];
end
if nargout>=3
wr=flipud(wl);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function w = channing(m,n)
w = .5*(1 - cos(2*pi*(1:m)'/(n+1)));