summaryrefslogtreecommitdiff
path: root/macros/bartlett.sci
blob: b450e7ca01d2fac71c228811cc3e9c11cea1349c (plain)
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
function w=bartlett(L)
//Generates a Bartlett window
//Calling Sequence
//w=bartlett(L)
//Parameters
//L
//A positive integer describing the length of the bartlett window
//Description
//w=bartlett(L) returns an L-point Bartlett window in a column vector w
//Example
//w=bartlett(4)
// w  =
// 
//    0.         
//    0.6666667  
//    0.6666667  
//    0.
//Author
//Ankur Mallick
//References
//[1] Oppenheim, Alan V., Ronald W. Schafer, and John R. Buck. Discrete-Time Signal Processing. Upper Saddle River, NJ: Prentice Hall, 1999.
    funcprot(0);
    if(argn(2)~=1)
        error('Incorrect number of input arguments.');
    elseif(~isscalar(L)|L<=0|round(L)~=L)
        error('L must be a positive integer')
    elseif(L==1)
        w=1; //Trivial case
    else
        N=L-1;
        w1=2*(0:1:N/2)/N;
        w2=2-2*(floor(N/2)+1:1:N)/N; //floor used to adjust for odd/even
        w=[w1, w2]';
    end
endfunction