"Fossies" - the Fresh Open Source Software Archive

Member "MACE1.6.0/exampleScripts/discrete_signals.txt" (28 Mar 2019, 1377 Bytes) of package /windows/misc/MACE1.6.0.zip:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 %Copyright (C) 2019 Jan Christian Rohde
    2 %
    3 %This file is part of MACE.
    4 %
    5 %MACE is free software; you can redistribute it and/or modify it under the terms of the
    6 %GNU General Public License as published by the Free Software Foundation; either version 3
    7 %of the License, or (at your option) any later version.
    8 %
    9 %MACE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
   10 %even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11 %GNU General Public License for more details.
   12 %
   13 %You should have received a copy of the GNU General Public License
   14 %along with MACE; if not, see http://www.gnu.org/licenses.
   15 
   16 % This script contains examples concerning discrete signals.
   17 
   18 setCharacteristic(0)
   19 
   20 % First sample a discrete signal with frequencies 1 / (2 pi) and 1 / (4 pi)
   21 
   22 s=sampling(cos(x)+sin(x/2),1,0,100):
   23 
   24 % fast fourier transform
   25 
   26 f=fft(s):
   27 plot(abs(f));
   28 
   29 % filter the signal with low frequency 1 / (4 pi)
   30 
   31 p=lowPass(s,0.1);
   32 plot(sin(x/2),real(p));
   33 
   34 % An iir system and its impulse response:
   35 % Note the system is the one given by the polynomials with inverted powers
   36 % with respect to usual conventions 2*x^(-3)+6*x^(-2)+2*x,1.5+1.2*x^(-5)
   37 
   38 s=setSize(seq(1),100):
   39 r=iir(s,2*x^3+6*x^2+2*x,1.5+1.2*x^5):
   40 
   41 % you should enlarge the x-axis domain of the plot by hand to see more of the
   42 % impulse response
   43 
   44 plot(real(r));