summaryrefslogtreecommitdiff
path: root/macros/gaussian.sci
diff options
context:
space:
mode:
authorRashmi2024-08-07 15:34:47 +0530
committerRashmi2024-08-07 15:34:47 +0530
commitf8ae45ed71b709b3308a472ca00d641d6ba0fda3 (patch)
tree73406f2fccc8902c3f0854429ae3bc547978157b /macros/gaussian.sci
parent91f8045f58b6b96dbaaf2d4400586660b92d461c (diff)
downloadFOSSEE-Signal-Processing-Toolbox-f8ae45ed71b709b3308a472ca00d641d6ba0fda3.tar.gz
FOSSEE-Signal-Processing-Toolbox-f8ae45ed71b709b3308a472ca00d641d6ba0fda3.tar.bz2
FOSSEE-Signal-Processing-Toolbox-f8ae45ed71b709b3308a472ca00d641d6ba0fda3.zip
Corrected the code
Diffstat (limited to 'macros/gaussian.sci')
-rw-r--r--macros/gaussian.sci57
1 files changed, 23 insertions, 34 deletions
diff --git a/macros/gaussian.sci b/macros/gaussian.sci
index 59ddb3c..234512e 100644
--- a/macros/gaussian.sci
+++ b/macros/gaussian.sci
@@ -1,34 +1,23 @@
-function w = gaussian (m, a)
-//This function returns a Gaussian convolution window.
-//Calling Sequence
-//w = gaussian (m)
-//w = gaussian (m, a)
-//Parameters
-//m: positive integer value
-//a:
-//w: output variable, vector of real numbers
-//Description
-//This is an Octave function.
-//This function returns a Gaussian convolution window of length m supplied as input, to the output vector w.
-//The second parameter is the width measured in sample rate/number of samples and should be f for time domain and 1/f for frequency domain. The width is inversely proportional to a.
-//Examples
-//gaussian(5,6)
-//ans =
-// 5.380D-32
-// 1.523D-08
-// 1.
-// 1.523D-08
-// 5.380D-32
-
-funcprot(0);
-rhs = argn(2)
-if(rhs<1 | rhs>2)
-error("Wrong number of input arguments.")
-end
-if(rhs==1)
-w = callOctave("gaussian",m)
-elseif(rhs==2)
-w = callOctave("gaussian",m, a)
-end
-endfunction
-
+//Author: Rashmi Patankar
+//This function returns a Gaussian convolution window.
+//Calling Sequence
+//w = gaussian (m)
+//w = gaussian (m, a)
+//Parameters
+//m: positive integer value
+//a: integer value
+//w: output variable, vector of real numbers
+//Description
+//This function returns a Gaussian convolution window of length m supplied as input, to the output vector w.
+//The second parameter is the width measured in sample rate/number of samples and should be f for time domain and 1/f for frequency domain. The width is inversely proportional to a.
+function w = gaussian(m, a)
+ if nargin < 1 | nargin > 2 then
+ error('gaussian: Incorrect number of input arguments');
+ elseif ~(isscalar(m) & m == fix(m) & m > 0) then
+ error('gaussian: M must be a positive integer');
+ elseif nargin == 1 then
+ a = 1;
+ end
+
+ w = exp(-0.5 * (([0:m-1]' - (m-1)/2) .* a).^2);
+endfunction