summaryrefslogtreecommitdiff
path: root/macros/hanning.sci
blob: e206eaf6790933b50ceaa85c208e21809fbfe825 (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
function c = hanning (m, opt)

 funcprot(0);
    rhs= argn(2);

  if (rhs < 1 | rhs > 2)
     error("Wrong Number of input arguments");
  end

  if (~ (isscalar (m) & (m == fix (m)) & (m > 0)))
    error ("hanning: M must be a positive integer");
  end

  N = m - 1;
  if (rhs == 2)
    select (opt)
      case "periodic"
        N = m;
      case "symmetric"
        //Default option, same as no option specified.
      else
        error ('hanning: window type must be either periodic or symmetric");
    end
  end

  if (m == 1)
    c = 1;
  else
    m = m - 1;
    c = 0.5 - 0.5 * cos (2 * %pi * (0 : m)' / N);
  end

endfunction