diff options
Diffstat (limited to 'macros/mexihat.sci')
-rw-r--r-- | macros/mexihat.sci | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/macros/mexihat.sci b/macros/mexihat.sci index febad61..3147d53 100644 --- a/macros/mexihat.sci +++ b/macros/mexihat.sci @@ -5,12 +5,13 @@ // you should have received as part of this distribution. The terms // are also available at // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt -// Last Modified by : Abinash Singh , FOSSEE Winter Intern +// Author:[insert name] // Organization: FOSSEE, IIT Bombay // Email: toolbox@scilab.in -function [psi,x]=mexihat(lb,ub,n) + +function [psi,x]=mexihat(lb,ub,n) // Generates Mexican Hat wavelet // Calling Sequence // [psi,x]=mexihat(lb,ub,n) @@ -29,22 +30,26 @@ function [psi,x]=mexihat(lb,ub,n) // a = [0;0;0] // b = [1;1;1] - funcprot(0); - [nargout,nargin]=argn(); - x=[];psi=[]; +funcprot(0); + +[nargout,nargin]=argn(); + if (nargin < 3) - error("wrong number of input arguments"); - end + error("wrong number of input arguments"); + end + if (n <= 0) error("n must be strictly positive"); end - if(isscalar(lb)) - x = linspace(lb,ub,n); - psi = (1-x.^2).*(2/(sqrt(3)*%pi^0.25)) .* exp(-x.^2/2) ; - else + + if(isvector(lb)) for(i=1:length(lb)) - x(i) = linspace(lb(i),ub,n); - psi(i) = (1-x(i).^2).*(2/(sqrt(3)*%pi^0.25)) .* exp(-x(i).^2/2) ; - end + x(i) = linspace(lb(i),ub,n); + psi(i) = (1-x(i).^2).*(2/(sqrt(3)*%pi^0.25)) .* exp(-x(i).^2/2) ; end + +else + x = linspace(lb,ub,n); + psi = (1-x.^2).*(2/(sqrt(3)*%pi^0.25)) .* exp(-x.^2/2) ; +end endfunction |