File: sincd.sci

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (36 lines) | stat: -rw-r--r-- 827 bytes parent folder | download | duplicates (2)
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
function [s]=sincd(n,flag)
//<s>=sincd(n,flag)
//macro which calculates the function Sin(N*x)/Sin(x)
//  n    : value of N in the preceding function
//  flag : flag=1 : the function is centered around the origin
//       : flag=2 : the function is delayed by %pi/(2*n)
//  s    : vector of values of the function on a dense
//       : grid of frequencies
//!
//author: G. Le Vey  Date: 1 Febr 1989
// Copyright INRIA

   npt=4*n;
   pas=%pi/npt;
   om=0:pas:%pi;
   eps=(-1)**(n-1);
   select flag
   case 1,
   s1=sin(n*om);s2=sin(om);
   s1(1)=n;s2(1)=1;s1(npt+1)=n*eps;s2(npt+1)=1;
   s=s1./s2;
   s=[s(npt+1:-1:2) s];
   s=s/n;
   case 2,
   om=om-ones(om)*%pi/2/n;
   s1=sin(n*om);
   s2=sin(om);
   s1(3)=n;s2(3)=1;
   s=s1./s2;
   s=[eps*s s(2:npt+1)];
   s=s/n;
   else,error('flag must be equal to 1 or 2')
   end;