File: ifftshift.dia.ref

package info (click to toggle)
scilab 6.0.1-10%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 365,292 kB
  • sloc: xml: 827,376; cpp: 273,125; ansic: 216,672; java: 190,706; fortran: 90,783; ml: 24,107; tcl: 16,853; sh: 13,608; makefile: 9,556; lex: 1,615; perl: 1,566; yacc: 1,263; php: 690; cs: 614
file content (31 lines) | stat: -rw-r--r-- 1,103 bytes parent folder | download
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
//<-- CLI SHELL MODE -->
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
//
//  This file is distributed under the same license as the Scilab package.
// =============================================================================
//
// <-- CLLI SHELL MODE -->
vec = 1:60;
res = ifftshift(vec);
assert_checkequal(res(1:30), 31:60);
assert_checkequal(res(31:60), 1:30);
mat = matrix(vec, [10 6]);
refRES = (1:5)';
refRES = [refRES refRES+10 refRES+20];
res = ifftshift(mat);
assert_checkequal(res(1:5, 1:3), refRES+35);
assert_checkequal(res(1:5, 4:6), refRES+5);
assert_checkequal(res(6:10, 1:3), refRES+30);
assert_checkequal(res(6:10, 4:6), refRES);
// Check that ifftshift(fftshift(x)) = x
// Make a signal
t = 0:0.1:1000;
x = 3*sin(t)+8*sin(3*t)+0.5*sin(5*t)+3*rand(t);
// Compute the fft
y = fft(x, -1);
// Invert the result
invShift = ifftshift(fftshift(y));
// Check that we recreated the original result
assert_checkequal(invShift, y);