summaryrefslogtreecommitdiff
path: root/macros/fft1.sci
diff options
context:
space:
mode:
authorbgtushar2017-11-30 14:54:09 +0530
committerGitHub2017-11-30 14:54:09 +0530
commit99b498fb0cedd8560d18f032a4cb1fcae0c1fadb (patch)
tree7dc4d248208dd3ea7dac6e4ffb056f9b16a601eb /macros/fft1.sci
parent14d0ad8d846d12b3c82b0b5bc4ffd4d1360ec288 (diff)
parent9d18f39d1775acd7f96e2388b186bb15068ff910 (diff)
downloadFOSSEE-Signal-Processing-Toolbox-99b498fb0cedd8560d18f032a4cb1fcae0c1fadb.tar.gz
FOSSEE-Signal-Processing-Toolbox-99b498fb0cedd8560d18f032a4cb1fcae0c1fadb.tar.bz2
FOSSEE-Signal-Processing-Toolbox-99b498fb0cedd8560d18f032a4cb1fcae0c1fadb.zip
Merge pull request #8 from Brijeshcr/master
Added new functions
Diffstat (limited to 'macros/fft1.sci')
-rw-r--r--macros/fft1.sci49
1 files changed, 49 insertions, 0 deletions
diff --git a/macros/fft1.sci b/macros/fft1.sci
new file mode 100644
index 0000000..a0a6438
--- /dev/null
+++ b/macros/fft1.sci
@@ -0,0 +1,49 @@
+function res = fft1 (x, n, dim)
+//Calculates the discrete Fourier transform of a matrix using Fast Fourier Transform algorithm.
+//Calling Sequence
+//fft (x, n, dim)
+//fft (x, n)
+//fft (x)
+//Parameters
+//x: input matrix
+//n: Specifies the number of elements of x to be used
+//dim: Specifies the dimention of the matrix along which the FFT is performed
+//Description
+//This is an Octave function.
+//The FFT is calculated along the first non-singleton dimension of the array. Thus, FFT is computed for each column of x.
+//
+//n is an integer specifying the number of elements of x to use. If n is larger than dimention along. which the FFT is calculated, then x is resized and padded with zeros.
+//Similarly, if n is smaller, then x is truncated.
+//
+//dim is an integer specifying the dimension of the matrix along which the FFT is performed.
+//Examples
+//x = [1 2 3; 4 5 6; 7 8 9]
+//n = 3
+//dim = 2
+//fft1 (x, n, dim)
+//ans =
+//
+// 6.0000 + 0.0000i -1.5000 + 0.8660i -1.5000 - 0.8660i
+// 15.0000 + 0.0000i -1.5000 + 0.8660i -1.5000 - 0.8660i
+// 24.0000 + 0.0000i -1.5000 + 0.8660i -1.5000 - 0.8660i
+
+funcprot(0);
+lhs = argn(1)
+rhs = argn(2)
+if (rhs < 1 | rhs > 3)
+error("Wrong number of input arguments.")
+end
+
+select(rhs)
+
+ case 1 then
+ res = callOctave("fft", x)
+
+ case 2 then
+ res = callOctave("fft", x, n)
+
+ case 3 then
+ res = callOctave("fft", x, n, dim)
+
+ end
+endfunction