Diff of the two buildlogs: -- --- b1/build.log 2024-05-11 11:19:58.506639436 +0000 +++ b2/build.log 2024-05-11 11:27:55.870306657 +0000 @@ -1,6 +1,6 @@ I: pbuilder: network access will be disabled during build -I: Current time: Fri May 10 23:10:13 -12 2024 -I: pbuilder-time-stamp: 1715425813 +I: Current time: Sat Jun 14 07:43:10 +14 2025 +I: pbuilder-time-stamp: 1749836590 I: Building the build Environment I: extracting base tarball [/var/cache/pbuilder/trixie-reproducible-base.tgz] I: copying local configuration @@ -31,52 +31,84 @@ dpkg-source: info: applying xcorr-doc-conjugation.patch I: Not using root during the build. I: Installing the build-deps -I: user script /srv/workspace/pbuilder/2814748/tmp/hooks/D02_print_environment starting +I: user script /srv/workspace/pbuilder/144433/tmp/hooks/D01_modify_environment starting +debug: Running on ionos15-amd64. +I: Changing host+domainname to test build reproducibility +I: Adding a custom variable just for the fun of it... +I: Changing /bin/sh to bash +'/bin/sh' -> '/bin/bash' +lrwxrwxrwx 1 root root 9 Jun 13 17:43 /bin/sh -> /bin/bash +I: Setting pbuilder2's login shell to /bin/bash +I: Setting pbuilder2's GECOS to second user,second room,second work-phone,second home-phone,second other +I: user script /srv/workspace/pbuilder/144433/tmp/hooks/D01_modify_environment finished +I: user script /srv/workspace/pbuilder/144433/tmp/hooks/D02_print_environment starting I: set - BUILDDIR='/build/reproducible-path' - BUILDUSERGECOS='first user,first room,first work-phone,first home-phone,first other' - BUILDUSERNAME='pbuilder1' - BUILD_ARCH='amd64' - DEBIAN_FRONTEND='noninteractive' - DEB_BUILD_OPTIONS='buildinfo=+all reproducible=+all parallel=20 ' - DISTRIBUTION='trixie' - HOME='/root' - HOST_ARCH='amd64' + BASH=/bin/sh + BASHOPTS=checkwinsize:cmdhist:complete_fullquote:extquote:force_fignore:globasciiranges:globskipdots:hostcomplete:interactive_comments:patsub_replacement:progcomp:promptvars:sourcepath + BASH_ALIASES=() + BASH_ARGC=() + BASH_ARGV=() + BASH_CMDS=() + BASH_LINENO=([0]="12" [1]="0") + BASH_LOADABLES_PATH=/usr/local/lib/bash:/usr/lib/bash:/opt/local/lib/bash:/usr/pkg/lib/bash:/opt/pkg/lib/bash:. + BASH_SOURCE=([0]="/tmp/hooks/D02_print_environment" [1]="/tmp/hooks/D02_print_environment") + BASH_VERSINFO=([0]="5" [1]="2" [2]="21" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu") + BASH_VERSION='5.2.21(1)-release' + BUILDDIR=/build/reproducible-path + BUILDUSERGECOS='second user,second room,second work-phone,second home-phone,second other' + BUILDUSERNAME=pbuilder2 + BUILD_ARCH=amd64 + DEBIAN_FRONTEND=noninteractive + DEB_BUILD_OPTIONS='buildinfo=+all reproducible=+all parallel=42 ' + DIRSTACK=() + DISTRIBUTION=trixie + EUID=0 + FUNCNAME=([0]="Echo" [1]="main") + GROUPS=() + HOME=/root + HOSTNAME=i-capture-the-hostname + HOSTTYPE=x86_64 + HOST_ARCH=amd64 IFS=' ' - INVOCATION_ID='adc1ca18c64f4c17854c57e591c5e3b4' - LANG='C' - LANGUAGE='en_US:en' - LC_ALL='C' - MAIL='/var/mail/root' - OPTIND='1' - PATH='/usr/sbin:/usr/bin:/sbin:/bin:/usr/games' - PBCURRENTCOMMANDLINEOPERATION='build' - PBUILDER_OPERATION='build' - PBUILDER_PKGDATADIR='/usr/share/pbuilder' - PBUILDER_PKGLIBDIR='/usr/lib/pbuilder' - PBUILDER_SYSCONFDIR='/etc' - PPID='2814748' - PS1='# ' - PS2='> ' + INVOCATION_ID=a2ad535afd3e4c99bc2b4eb15709e027 + LANG=C + LANGUAGE=et_EE:et + LC_ALL=C + MACHTYPE=x86_64-pc-linux-gnu + MAIL=/var/mail/root + OPTERR=1 + OPTIND=1 + OSTYPE=linux-gnu + PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/i/capture/the/path + PBCURRENTCOMMANDLINEOPERATION=build + PBUILDER_OPERATION=build + PBUILDER_PKGDATADIR=/usr/share/pbuilder + PBUILDER_PKGLIBDIR=/usr/lib/pbuilder + PBUILDER_SYSCONFDIR=/etc + PIPESTATUS=([0]="0") + POSIXLY_CORRECT=y + PPID=144433 PS4='+ ' - PWD='/' - SHELL='/bin/bash' - SHLVL='2' - SUDO_COMMAND='/usr/bin/timeout -k 18.1h 18h /usr/bin/ionice -c 3 /usr/bin/nice /usr/sbin/pbuilder --build --configfile /srv/reproducible-results/rbuild-debian/r-b-build.ByHh3rtz/pbuilderrc_DGj3 --distribution trixie --hookdir /etc/pbuilder/first-build-hooks --debbuildopts -b --basetgz /var/cache/pbuilder/trixie-reproducible-base.tgz --buildresult /srv/reproducible-results/rbuild-debian/r-b-build.ByHh3rtz/b1 --logfile b1/build.log octave-signal_1.4.5-2.dsc' - SUDO_GID='111' - SUDO_UID='106' - SUDO_USER='jenkins' - TERM='unknown' - TZ='/usr/share/zoneinfo/Etc/GMT+12' - USER='root' - _='/usr/bin/systemd-run' - http_proxy='http://46.16.76.132:3128' + PWD=/ + SHELL=/bin/bash + SHELLOPTS=braceexpand:errexit:hashall:interactive-comments:posix + SHLVL=3 + SUDO_COMMAND='/usr/bin/timeout -k 24.1h 24h /usr/bin/ionice -c 3 /usr/bin/nice -n 11 /usr/bin/unshare --uts -- /usr/sbin/pbuilder --build --configfile /srv/reproducible-results/rbuild-debian/r-b-build.ByHh3rtz/pbuilderrc_XLBk --distribution trixie --hookdir /etc/pbuilder/rebuild-hooks --debbuildopts -b --basetgz /var/cache/pbuilder/trixie-reproducible-base.tgz --buildresult /srv/reproducible-results/rbuild-debian/r-b-build.ByHh3rtz/b2 --logfile b2/build.log octave-signal_1.4.5-2.dsc' + SUDO_GID=111 + SUDO_UID=106 + SUDO_USER=jenkins + TERM=unknown + TZ=/usr/share/zoneinfo/Etc/GMT-14 + UID=0 + USER=root + _='I: set' + http_proxy=http://213.165.73.152:3128 I: uname -a - Linux ionos11-amd64 6.1.0-21-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.90-1 (2024-05-03) x86_64 GNU/Linux + Linux i-capture-the-hostname 6.6.13+bpo-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.6.13-1~bpo12+1 (2024-02-15) x86_64 GNU/Linux I: ls -l /bin - lrwxrwxrwx 1 root root 7 May 10 11:25 /bin -> usr/bin -I: user script /srv/workspace/pbuilder/2814748/tmp/hooks/D02_print_environment finished + lrwxrwxrwx 1 root root 7 Jun 11 17:46 /bin -> usr/bin +I: user script /srv/workspace/pbuilder/144433/tmp/hooks/D02_print_environment finished -> Attempting to satisfy build-dependencies -> Creating pbuilder-satisfydepends-dummy package Package: pbuilder-satisfydepends-dummy @@ -691,7 +723,7 @@ Get: 566 http://deb.debian.org/debian trixie/main amd64 texlive-latex-base all 2023.20240207-1 [1255 kB] Get: 567 http://deb.debian.org/debian trixie/main amd64 texlive-latex-recommended all 2023.20240207-1 [8843 kB] Get: 568 http://deb.debian.org/debian trixie/main amd64 texlive all 2023.20240207-1 [18.2 kB] -Fetched 294 MB in 12s (24.8 MB/s) +Fetched 294 MB in 4s (70.0 MB/s) debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package libpython3.11-minimal:amd64. (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 19699 files and directories currently installed.) @@ -2528,8 +2560,8 @@ Setting up tzdata (2024a-4) ... Current default time zone: 'Etc/UTC' -Local time is now: Sat May 11 11:14:04 UTC 2024. -Universal Time is now: Sat May 11 11:14:04 UTC 2024. +Local time is now: Fri Jun 13 17:45:26 UTC 2025. +Universal Time is now: Fri Jun 13 17:45:26 UTC 2025. Run 'dpkg-reconfigure tzdata' if you wish to change it. Setting up liberror-perl (0.17029-2) ... @@ -3043,7 +3075,11 @@ Building tag database... -> Finished parsing the build-deps I: Building the package -I: Running cd /build/reproducible-path/octave-signal-1.4.5/ && env PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" HOME="/nonexistent/first-build" dpkg-buildpackage -us -uc -b && env PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" HOME="/nonexistent/first-build" dpkg-genchanges -S > ../octave-signal_1.4.5-2_source.changes +I: user script /srv/workspace/pbuilder/144433/tmp/hooks/A99_set_merged_usr starting +Not re-configuring usrmerge for trixie +I: user script /srv/workspace/pbuilder/144433/tmp/hooks/A99_set_merged_usr finished +hostname: Name or service not known +I: Running cd /build/reproducible-path/octave-signal-1.4.5/ && env PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/i/capture/the/path" HOME="/nonexistent/second-build" dpkg-buildpackage -us -uc -b && env PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/i/capture/the/path" HOME="/nonexistent/second-build" dpkg-genchanges -S > ../octave-signal_1.4.5-2_source.changes dpkg-buildpackage: info: source package octave-signal dpkg-buildpackage: info: source version 1.4.5-2 dpkg-buildpackage: info: source distribution unstable @@ -3055,7 +3091,7 @@ dh_auto_clean -O--buildsystem=octave dh_octave_clean make[1]: Entering directory '/build/reproducible-path/octave-signal-1.4.5' -/bin/sh: 1: hg: not found +/bin/sh: line 1: hg: command not found make[1]: hg: No such file or directory rm -f -f doc/signal.html rm -f -f doc/signal.qhc @@ -3090,7 +3126,7 @@ chmod +x doc/mkfuncdocs.py doc/mkqhcp.py make -k doc make[2]: Entering directory '/build/reproducible-path/octave-signal-1.4.5' -/bin/sh: 1: hg: not found +/bin/sh: line 1: hg: command not found make[2]: hg: No such file or directory cd doc && ./mkfuncdocs.py --src-dir=../inst/ --src-dir=../src/ ../INDEX | sed 's/@seealso/@xseealso/g' > functions.texi Generating doc/version.texi @@ -3391,24 +3427,24 @@ make[1]: Entering directory '/build/reproducible-path/octave-signal-1.4.5/src' /usr/bin/mkoctfile --verbose -Wall __fwht__.cc -o __fwht__.oct /usr/bin/mkoctfile --verbose -Wall __ultrwin__.cc -o __ultrwin__.oct +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall __fwht__.cc -o /tmp/oct-hoLfdM.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall __ultrwin__.cc -o /tmp/oct-Brnq5n.o /usr/bin/mkoctfile --verbose -Wall -c cl2bp.cc -o cl2bp.o /usr/bin/mkoctfile --verbose -Wall -c cl2bp_lib.cc -o cl2bp_lib.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall cl2bp.cc -o cl2bp.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall cl2bp_lib.cc -o cl2bp_lib.o /usr/bin/mkoctfile --verbose -Wall -c firpm.cc -o firpm.o -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall __fwht__.cc -o /tmp/oct-5Wtojk.o /usr/bin/mkoctfile --verbose -c mmfir.c -o mmfir.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall firpm.cc -o firpm.o /usr/bin/mkoctfile --verbose -Wall medfilt1.cc -o medfilt1.oct -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall __ultrwin__.cc -o /tmp/oct-1wRyM4.o -/usr/bin/mkoctfile --verbose -Wall remez.cc -o remez.oct -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall cl2bp.cc -o cl2bp.o -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall cl2bp_lib.cc -o cl2bp_lib.o gcc -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection mmfir.c -o mmfir.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall medfilt1.cc -o /tmp/oct-QDPEKh.o +/usr/bin/mkoctfile --verbose -Wall remez.cc -o remez.oct /usr/bin/mkoctfile --verbose -Wall sosfilt.cc -o sosfilt.oct -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall medfilt1.cc -o /tmp/oct-wGhHfs.o -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall firpm.cc -o firpm.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall remez.cc -o /tmp/oct-rwcDWB.o /usr/bin/mkoctfile --verbose -Wall upfirdn.cc -o upfirdn.oct -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall remez.cc -o /tmp/oct-tiibWs.o -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall sosfilt.cc -o /tmp/oct-CkHN5X.o -g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall upfirdn.cc -o /tmp/oct-wbtpNH.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall sosfilt.cc -o /tmp/oct-bUuLjW.o +g++ -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall upfirdn.cc -o /tmp/oct-XDvTKd.o mmfir.c: In function 'mmfir': mmfir.c:608:37: warning: '%i' directive writing between 1 and 11 bytes into a region of size 7 [-Wformat-overflow=] 608 | char name[9], dummy = (char)sprintf(name, "sp%i", report.iterations); @@ -3439,14 +3475,14 @@ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 32 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ -g++ -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -o __fwht__.oct /tmp/oct-5Wtojk.o -shared -Wl,-Bsymbolic -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -shared -Wl,-Bsymbolic -flto=auto -ffat-lto-objects -Wl,-z,relro -g++ -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -o __ultrwin__.oct /tmp/oct-1wRyM4.o -shared -Wl,-Bsymbolic -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -shared -Wl,-Bsymbolic -flto=auto -ffat-lto-objects -Wl,-z,relro +g++ -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -o sosfilt.oct /tmp/oct-bUuLjW.o -shared -Wl,-Bsymbolic -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -shared -Wl,-Bsymbolic -flto=auto -ffat-lto-objects -Wl,-z,relro +g++ -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -o __fwht__.oct /tmp/oct-hoLfdM.o -shared -Wl,-Bsymbolic -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -shared -Wl,-Bsymbolic -flto=auto -ffat-lto-objects -Wl,-z,relro +g++ -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -o medfilt1.oct /tmp/oct-QDPEKh.o -shared -Wl,-Bsymbolic -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -shared -Wl,-Bsymbolic -flto=auto -ffat-lto-objects -Wl,-z,relro /usr/bin/mkoctfile --verbose -Wall cl2bp.o cl2bp_lib.o -o cl2bp.oct g++ -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -o cl2bp.oct cl2bp.o cl2bp_lib.o -shared -Wl,-Bsymbolic -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -shared -Wl,-Bsymbolic -flto=auto -ffat-lto-objects -Wl,-z,relro -g++ -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -o medfilt1.oct /tmp/oct-wGhHfs.o -shared -Wl,-Bsymbolic -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -shared -Wl,-Bsymbolic -flto=auto -ffat-lto-objects -Wl,-z,relro -g++ -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -o sosfilt.oct /tmp/oct-CkHN5X.o -shared -Wl,-Bsymbolic -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -shared -Wl,-Bsymbolic -flto=auto -ffat-lto-objects -Wl,-z,relro -g++ -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -o upfirdn.oct /tmp/oct-wbtpNH.o -shared -Wl,-Bsymbolic -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -shared -Wl,-Bsymbolic -flto=auto -ffat-lto-objects -Wl,-z,relro -g++ -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -o remez.oct /tmp/oct-tiibWs.o -shared -Wl,-Bsymbolic -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -shared -Wl,-Bsymbolic -flto=auto -ffat-lto-objects -Wl,-z,relro +g++ -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -o remez.oct /tmp/oct-rwcDWB.o -shared -Wl,-Bsymbolic -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -shared -Wl,-Bsymbolic -flto=auto -ffat-lto-objects -Wl,-z,relro +g++ -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -o upfirdn.oct /tmp/oct-XDvTKd.o -shared -Wl,-Bsymbolic -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -shared -Wl,-Bsymbolic -flto=auto -ffat-lto-objects -Wl,-z,relro +g++ -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -o __ultrwin__.oct /tmp/oct-Brnq5n.o -shared -Wl,-Bsymbolic -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -shared -Wl,-Bsymbolic -flto=auto -ffat-lto-objects -Wl,-z,relro /usr/bin/mkoctfile --verbose -Wall firpm.o mmfir.o -o firpm.oct g++ -I/usr/include/octave-8.4.0/octave/.. -I/usr/include/octave-8.4.0/octave -pthread -fopenmp -g -O2 -ffile-prefix-map=/build/reproducible-path/octave-signal-1.4.5=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -o firpm.oct firpm.o mmfir.o -shared -Wl,-Bsymbolic -Wl,-z,relro -L/usr/lib/x86_64-linux-gnu -shared -Wl,-Bsymbolic -flto=auto -ffat-lto-objects -Wl,-z,relro make[1]: Leaving directory '/build/reproducible-path/octave-signal-1.4.5/src' @@ -3457,1069 +3493,1487 @@ Checking package... Run the unit tests... Checking m files ... -[inst/udecode.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/udecode.m +[inst/chirp.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/chirp.m +***** demo + t = 0:0.001:5; + y = chirp (t); + specgram (y, 256, 1000); + %------------------------------------------------------------ + % Shows linear sweep of 100 Hz/sec starting at zero for 5 sec + % since the sample rate is 1000 Hz, this should be a diagonal + % from bottom left to top right. +***** demo + t = -2:0.001:15; + y = chirp (t, 400, 10, 100, "quadratic"); + [S, f, t] = specgram (y, 256, 1000); + t = t - 2; + imagesc(t, f, 20 * log10 (abs (S))); + set (gca (), "ydir", "normal"); + xlabel ("Time"); + ylabel ("Frequency"); + %------------------------------------------------------------ + % Shows a quadratic chirp of 400 Hz at t=0 and 100 Hz at t=10 + % Time goes from -2 to 15 seconds. +***** demo + t = 0:1/8000:5; + y = chirp (t, 200, 2, 500, "logarithmic"); + specgram (y, 256, 8000); + %------------------------------------------------------------- + % Shows a logarithmic chirp of 200 Hz at t=0 and 500 Hz at t=2 + % Time goes from 0 to 5 seconds at 8000 Hz. +***** shared t + t = (0:5000) ./ 1000; ***** test - u = [0 0 0 0 0 1 2 3 3 3 3 3 3]; - y = udecode(u, 2); - assert(y, [-1 -1 -1 -1 -1 -0.5 0 0.5 0.5 0.5 0.5 0.5 0.5]); + y1 = chirp (t); + y2 = chirp (t, 0, 1, 100, "linear", 0); + assert (y2, y1) ***** test - u = [0 1 2 3 4 5 6 7 8 9 10]; - y = udecode(u, 2, 1, "saturate"); - assert(y, [-1 -0.5 0 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5]); + y1 = chirp (t, [], [], [], "li"); + y2 = chirp (t, 0, 1, 100, "linear", 0); + assert (y2, y1) ***** test - u = [0 1 2 3 4 5 6 7 8 9 10]; - y = udecode(u, 2, 1, "wrap"); - assert(y, [-1 -0.5 0 0.5 -1 -0.5 0 0.5 -1 -0.5 0]); + y1 = chirp (t, [], [], [], "q"); + y2 = chirp (t, 0, 1, 100, "quadratic", 0); + assert (y2, y1) ***** test - u = [-4 -3 -2 -1 0 1 2 3]; - y = udecode(u, 3, 2); - assert(y, [-2, -1.5 -1 -0.5 0 0.5 1 1.5]); + y1 = chirp (t, [], [], [], "lo"); + y2 = chirp (t, 1e-6, 1, 100, "logarithmic", 0); + assert (y2, y1) +***** error chirp () +***** error chirp (1, 2, 3, 4, 5, 6, 7) +***** error chirp (0, [], [], [], "l") +***** error chirp (0, [], [], [], "foo") +8 tests, 8 passed, 0 known failure, 0 skipped +[inst/triang.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/triang.m +***** assert (triang (1), 1) +***** assert (triang (2), [1; 1]/2) +***** assert (triang (3), [1; 2; 1]/2) +***** assert (triang (4), [1; 3; 3; 1]/4) ***** test - u = [-7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7]; - y = udecode(u, 3, 2, "saturate"); - assert(y, [-2 -2 -2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 1.5 1.5 1.5 1.5]); + x = bartlett (5); + assert (triang (3), x(2:4)); +***** error triang () +***** error triang (0.5) +***** error triang (-1) +***** error triang (ones (1, 4)) +***** error triang (1, 2) +***** demo + subplot(221); + n=7; k=(n-1)/2; t=[-k:0.1:k]/(k+1); + plot(t,1-abs(t),";continuous;",[-k:k]/(k+1),triang(n),"g*;discrete;"); + axis([-1, 1, 0, 1.3]); grid("on"); + title("comparison with continuous for odd n"); + + subplot(222); + n=8; k=(n-1)/2; t=[-k:0.1:k]/(k+1/2); + plot(t,1+1/n-abs(t),";continuous;",[-k:k]/(k+1/2),triang(n),"g*;discrete;"); + axis([-1, 1, 0, 1.3]); grid("on"); + title("note the higher peak for even n"); + + subplot(223); + n=7; + plot(0:n+1,bartlett(n+2),"g-*;bartlett;",triang(n),"r-+;triang;"); + axis; grid("off"); + title("n odd, triang(n)==bartlett(n+2)"); + + subplot(224); + n=8; + plot(0:n+1,bartlett(n+2),"g-*;bartlett;",triang(n),"r-+;triang;"); + axis; grid("off"); + title("n even, triang(n)!=bartlett(n+2)"); +10 tests, 10 passed, 0 known failure, 0 skipped +[inst/unshiftdata.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/unshiftdata.m ***** test - u = [-7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7]; - y = udecode(u, 3, 2, "wrap"); - assert(y, [0.5 1 1.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 -2 -1.5 -1 -0.5]); -***** error udecode () -***** error udecode (1) -***** error udecode (1, 2, 3, 4, 5) -***** error udecode (1.5) -***** error udecode (1, 100) -***** error udecode (1, 4, 0) -***** error udecode (1, 4, -1) -***** error udecode (1, 4, 2, "invalid") + x = 1:5; + [y, perm, shifts] = shiftdata (x); + x2 = unshiftdata (y, perm, shifts); + assert (x, x2); +***** test + X = fix (rand (3, 3) * 100); + [Y, perm, shifts] = shiftdata (X, 2); + X2 = unshiftdata (Y, perm, shifts); + assert (X, X2); +***** test + X = fix (rand (4, 4, 4, 4) * 100); + [Y, perm, shifts] = shiftdata (X, 3); + X2 = unshiftdata (Y, perm, shifts); + assert (X, X2); +***** test + X = fix (rand (1, 1, 3, 4) * 100); + [Y, perm, shifts] = shiftdata (X); + X2 = unshiftdata (Y, perm, shifts); + assert (X, X2); +***** error unshiftdata () +***** error unshiftdata (1, 2) +***** error unshiftdata (1, 2, 3, 4) +***** error unshiftdata (1, 2.5) +***** error unshiftdata (1, [], 2.5) +***** error unshiftdata (1, [], []) +10 tests, 10 passed, 0 known failure, 0 skipped +[inst/gausswin.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/gausswin.m +***** assert (gausswin (1), 1) +***** assert (gausswin (2), [exp(-3.125); exp(-3.125)]) +***** assert (gausswin (3), [exp(-3.125); 1; exp(-3.125)]) +***** error gausswin () +***** error gausswin (0.5) +***** error gausswin (-1) +***** error gausswin (ones (1, 4)) +***** error gausswin (1, 2, 3) +8 tests, 8 passed, 0 known failure, 0 skipped +[inst/cheb2ap.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cheb2ap.m +***** error cheb2ap (-1, 3) +***** error cheb2ap (3, -1) +***** demo + w=0:0.01:1000; + [z, p, k] = cheb2ap (3, 3); + [b, a] = zp2tf (z, p, k); + Gs = freqs (b, a, w); + semilogx (w, abs (Gs)); + xlabel('Frequency in rad/sec') + ylabel('Magnitude of G(s)'); + title('Type 2 Chebyshev Low-Pass Filter, k=3, 3 dB ripple in stop band') + grid; +2 tests, 2 passed, 0 known failure, 0 skipped +[inst/marcumq.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/marcumq.m +***** error marcumq (1) +***** error marcumq (-1, 1, 1, 1, 1) +***** error marcumq (-1, 1) +***** error marcumq (1, -1) +***** error marcumq (1, 1, 0) +***** error marcumq (1, 1, -1) +***** error marcumq (1, 1, 1.1) +***** test + a = [0.00; 0.05; 1.00; 2.00; 3.00; 4.00; 5.00; 6.00; 7.00; 8.00; 9.00; 10.00; + 11.00; 12.00; 13.00; 14.00; 15.00; 16.00; 17.00; 18.00; 19.00; 20.00; + 21.00; 22.00; 23.00; 24.00]; + b = [0.000000, 0.100000, 1.100000, 2.100000, 3.100000, 4.100000]; + Q = [1.000000, 0.995012, 0.546074, 0.110251, 0.008189, 0.000224; + 1.000000, 0.995019, 0.546487, 0.110554, 0.008238, 0.000226; + 1.000000, 0.996971, 0.685377, 0.233113, 0.034727, 0.002092; + 1.000000, 0.999322, 0.898073, 0.561704, 0.185328, 0.027068; + 1.000000, 0.999944, 0.985457, 0.865241, 0.526735, 0.169515; + 1.000000, 0.999998, 0.999136, 0.980933, 0.851679, 0.509876; + 1.000000, 1.000000, 0.999979, 0.998864, 0.978683, 0.844038; + 1.000000, 1.000000, 1.000000, 0.999973, 0.998715, 0.977300; + 1.000000, 1.000000, 1.000000, 1.000000, 0.999969, 0.998618; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999966; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000]; + q = marcumq (a, b); + assert (q, Q, 1e-6); +***** test + a = [0.00; 0.05; 1.00; 2.00; 3.00; 4.00; 5.00; 6.00; 7.00; 8.00; 9.00; 10.00; + 11.00; 12.00; 13.00; 14.00; 15.00; 16.00; 17.00; 18.00; 19.00; 20.00; + 21.00; 22.00; 23.00; 24.00]; + b = [5.100000, 6.100000, 7.100000, 8.100000, 9.100000, 10.10000]; + Q = [0.000002, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; + 0.000002, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; + 0.000049, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; + 0.001606, 0.000037, 0.000000, 0.000000, 0.000000, 0.000000; + 0.024285, 0.001420, 0.000032, 0.000000, 0.000000, 0.000000; + 0.161412, 0.022812, 0.001319, 0.000030, 0.000000, 0.000000; + 0.499869, 0.156458, 0.021893, 0.001256, 0.000028, 0.000000; + 0.839108, 0.493229, 0.153110, 0.021264, 0.001212, 0.000027; + 0.976358, 0.835657, 0.488497, 0.150693, 0.020806, 0.001180; + 0.998549, 0.975673, 0.833104, 0.484953, 0.148867, 0.020458; + 0.999965, 0.998498, 0.975152, 0.831138, 0.482198, 0.147437; + 1.000000, 0.999963, 0.998458, 0.974742, 0.829576, 0.479995; + 1.000000, 1.000000, 0.999962, 0.998426, 0.974411, 0.828307; + 1.000000, 1.000000, 1.000000, 0.999961, 0.998400, 0.974138; + 1.000000, 1.000000, 1.000000, 1.000000, 0.999960, 0.998378; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999960; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000]; + q = marcumq (a, b); + assert (q, Q, 1e-6); +***** test + a = [0.00; 0.05; 1.00; 2.00; 3.00; 4.00; 5.00; 6.00; 7.00; 8.00; 9.00; 10.00; + 11.00; 12.00; 13.00; 14.00; 15.00; 16.00; 17.00; 18.00; 19.00; 20.00; + 21.00; 22.00; 23.00; 24.00]; + b = [11.10000, 12.10000, 13.10000, 14.10000, 15.10000, 16.10000]; + Q = [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; + 0.000026, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; + 0.001155, 0.000026, 0.000000, 0.000000, 0.000000, 0.000000; + 0.020183, 0.001136, 0.000025, 0.000000, 0.000000, 0.000000; + 0.146287, 0.019961, 0.001120, 0.000025, 0.000000, 0.000000; + 0.478193, 0.145342, 0.019778, 0.001107, 0.000024, 0.000000; + 0.827253, 0.476692, 0.144551, 0.019625, 0.001096, 0.000024; + 0.973909, 0.826366, 0.475422, 0.143881, 0.019494, 0.001087; + 0.998359, 0.973714, 0.825607, 0.474333, 0.143304, 0.019381; + 0.999959, 0.998343, 0.973546, 0.824952, 0.473389, 0.142803; + 1.000000, 0.999959, 0.998330, 0.973400, 0.824380, 0.472564; + 1.000000, 1.000000, 0.999958, 0.998318, 0.973271, 0.823876; + 1.000000, 1.000000, 1.000000, 0.999958, 0.998307, 0.973158; + 1.000000, 1.000000, 1.000000, 1.000000, 0.999957, 0.998297; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999957; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000]; + q = marcumq (a, b); + assert (q, Q, 1e-6); +***** test + a = [0.00; 0.05; 1.00; 2.00; 3.00; 4.00; 5.00; 6.00; 7.00; 8.00; 9.00; 10.00; + 11.00; 12.00; 13.00; 14.00; 15.00; 16.00; 17.00; 18.00; 19.00; 20.00; + 21.00; 22.00; 23.00; 24.00]; + b = [17.10000, 18.10000, 19.10000]; + Q = [0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000; + 0.000000, 0.000000, 0.000000; + 0.000024, 0.000000, 0.000000; + 0.001078, 0.000024, 0.000000; + 0.019283, 0.001071, 0.000023; + 0.142364, 0.019197, 0.001065; + 0.471835, 0.141976, 0.019121; + 0.823429, 0.471188, 0.141630; + 0.973056, 0.823030, 0.470608; + 0.998289, 0.972965, 0.822671; + 0.999957, 0.998281, 0.972883; + 1.000000, 0.999957, 0.998274; + 1.000000, 1.000000, 0.999956; + 1.000000, 1.000000, 1.000000]; + q = marcumq (a, b); + assert (q, Q, 1e-6); +***** test + M = 2; + a = [0.00; 0.05; 1.00; 2.00; 3.00; 4.00; 5.00; 6.00; 7.00; 8.00; 9.00; 10.00; + 11.00; 12.00; 13.00; 14.00; 15.00; 16.00; 17.00; 18.00; 19.00; 20.00; + 21.00; 22.00; 23.00; 24.00]; + b = [ 0.00, 0.10, 2.10, 7.10, 12.10, 17.10]; + Q = [1.000000, 0.999987, 0.353353, 0.000000, 0.000000, 0.000000; + 1.000000, 0.999988, 0.353687, 0.000000, 0.000000, 0.000000; + 1.000000, 0.999992, 0.478229, 0.000000, 0.000000, 0.000000; + 1.000000, 0.999999, 0.745094, 0.000001, 0.000000, 0.000000; + 1.000000, 1.000000, 0.934771, 0.000077, 0.000000, 0.000000; + 1.000000, 1.000000, 0.992266, 0.002393, 0.000000, 0.000000; + 1.000000, 1.000000, 0.999607, 0.032264, 0.000000, 0.000000; + 1.000000, 1.000000, 0.999992, 0.192257, 0.000000, 0.000000; + 1.000000, 1.000000, 1.000000, 0.545174, 0.000000, 0.000000; + 1.000000, 1.000000, 1.000000, 0.864230, 0.000040, 0.000000; + 1.000000, 1.000000, 1.000000, 0.981589, 0.001555, 0.000000; + 1.000000, 1.000000, 1.000000, 0.998957, 0.024784, 0.000000; + 1.000000, 1.000000, 1.000000, 0.999976, 0.166055, 0.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 0.509823, 0.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 0.846066, 0.000032; + 1.000000, 1.000000, 1.000000, 1.000000, 0.978062, 0.001335; + 1.000000, 1.000000, 1.000000, 1.000000, 0.998699, 0.022409; + 1.000000, 1.000000, 1.000000, 1.000000, 0.999970, 0.156421; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.495223; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.837820; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.976328; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.998564; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999966; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000]; + q = marcumq (a, b, M); + assert (q, Q, 1e-6); +***** test + M = 5; + a = [0.00; 0.05; 1.00; 2.00; 3.00; 4.00; 5.00; 6.00; 7.00; 8.00; 9.00; 10.00; + 11.00; 12.00; 13.00; 14.00; 15.00; 16.00; 17.00; 18.00; 19.00; 20.00; + 21.00; 22.00; 23.00; 24.00]; + b = [ 0.00, 0.10, 2.10, 7.10, 12.10, 17.10]; + Q = [1.000000, 1.000000, 0.926962, 0.000000, 0.000000, 0.000000; + 1.000000, 1.000000, 0.927021, 0.000000, 0.000000, 0.000000; + 1.000000, 1.000000, 0.947475, 0.000001, 0.000000, 0.000000; + 1.000000, 1.000000, 0.980857, 0.000033, 0.000000, 0.000000; + 1.000000, 1.000000, 0.996633, 0.000800, 0.000000, 0.000000; + 1.000000, 1.000000, 0.999729, 0.011720, 0.000000, 0.000000; + 1.000000, 1.000000, 0.999990, 0.088999, 0.000000, 0.000000; + 1.000000, 1.000000, 1.000000, 0.341096, 0.000000, 0.000000; + 1.000000, 1.000000, 1.000000, 0.705475, 0.000002, 0.000000; + 1.000000, 1.000000, 1.000000, 0.933009, 0.000134, 0.000000; + 1.000000, 1.000000, 1.000000, 0.993118, 0.003793, 0.000000; + 1.000000, 1.000000, 1.000000, 0.999702, 0.045408, 0.000000; + 1.000000, 1.000000, 1.000000, 0.999995, 0.238953, 0.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 0.607903, 0.000001; + 1.000000, 1.000000, 1.000000, 1.000000, 0.896007, 0.000073; + 1.000000, 1.000000, 1.000000, 1.000000, 0.987642, 0.002480; + 1.000000, 1.000000, 1.000000, 1.000000, 0.999389, 0.034450; + 1.000000, 1.000000, 1.000000, 1.000000, 0.999988, 0.203879; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.565165; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.876284; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.984209; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999165; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999983; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000]; + q = marcumq (a, b, M); + assert (q, Q, 1e-6); +***** test + M = 10; + a = [0.00; 0.05; 1.00; 2.00; 3.00; 4.00; 5.00; 6.00; 7.00; 8.00; 9.00; 10.00; + 11.00; 12.00; 13.00; 14.00; 15.00; 16.00; 17.00; 18.00; 19.00; 20.00; + 21.00; 22.00; 23.00; 24.00]; + b = [ 0.00, 0.10, 2.10, 7.10, 12.10, 17.10]; + Q = [1.000000, 1.000000, 0.999898, 0.000193, 0.000000, 0.000000; + 1.000000, 1.000000, 0.999897, 0.000194, 0.000000, 0.000000; + 1.000000, 1.000000, 0.999931, 0.000416, 0.000000, 0.000000; + 1.000000, 1.000000, 0.999980, 0.002377, 0.000000, 0.000000; + 1.000000, 1.000000, 0.999997, 0.016409, 0.000000, 0.000000; + 1.000000, 1.000000, 0.999999, 0.088005, 0.000000, 0.000000; + 1.000000, 1.000000, 1.000000, 0.302521, 0.000000, 0.000000; + 1.000000, 1.000000, 1.000000, 0.638401, 0.000000, 0.000000; + 1.000000, 1.000000, 1.000000, 0.894322, 0.000022, 0.000000; + 1.000000, 1.000000, 1.000000, 0.984732, 0.000840, 0.000000; + 1.000000, 1.000000, 1.000000, 0.998997, 0.014160, 0.000000; + 1.000000, 1.000000, 1.000000, 0.999972, 0.107999, 0.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 0.391181, 0.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 0.754631, 0.000004; + 1.000000, 1.000000, 1.000000, 1.000000, 0.951354, 0.000266; + 1.000000, 1.000000, 1.000000, 1.000000, 0.995732, 0.006444; + 1.000000, 1.000000, 1.000000, 1.000000, 0.999843, 0.065902; + 1.000000, 1.000000, 1.000000, 1.000000, 0.999998, 0.299616; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.676336; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.925312; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.992390; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999679; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999995; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; + 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000]; + q = marcumq (a, b, M); + assert (q, Q, 1e-6); 14 tests, 14 passed, 0 known failure, 0 skipped -[inst/buttord.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/buttord.m +[inst/impinvar.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/impinvar.m +***** function err = stozerr(bs,as,fs) + + # number of time steps + n=100; + + # impulse invariant transform to z-domain + [bz az]=impinvar(bs,as,fs); + + # create sys object of transfer function + s=tf(bs,as); + + # calculate impulse response of continuous time system + # at discrete time intervals 1/fs + ys=impulse(s,(n-1)/fs,1/fs)'; + + # impulse response of discrete time system + yz=filter(bz,az,[1 zeros(1,n-1)]); + + # find rms error + err=sqrt(sum((yz*fs-ys).^2)/length(ys)); + endfunction + +***** assert(stozerr([1],[1 1],100),0,0.0001); +***** assert(stozerr([1],[1 2 1],100),0,0.0001); +***** assert(stozerr([1 1],[1 2 1],100),0,0.0002); +***** assert(stozerr([1],[1 3 3 1],100),0,0.0001); +***** assert(stozerr([1 1],[1 3 3 1],100),0,0.0001); +***** assert(stozerr([1 1 1],[1 3 3 1],100),0,0.0001); +***** assert(stozerr([1],[1 0 1],100),0,0.0001); +***** assert(stozerr([1 1],[1 0 1],100),0,0.0001); +***** assert(stozerr([1],[1 0 2 0 1],100),0,0.0001); +***** assert(stozerr([1 1],[1 0 2 0 1],100),0,0.0001); +***** assert(stozerr([1 1 1],[1 0 2 0 1],100),0,0.0001); +***** assert(stozerr([1 1 1 1],[1 0 2 0 1],100),0,0.0001); +12 tests, 12 passed, 0 known failure, 0 skipped +[inst/window.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/window.m +***** assert (window (@bartlett, 16), window ("bartlett", 16)) +***** assert (window (@hamming, 16), window ("hamming", 16)) +***** assert (window (@hanning, 16), window ("hanning", 16)) +***** assert (window (@triang, 16), window ("triang", 16)) +***** error window () +***** error window (1) +***** error window ("hanning") +7 tests, 7 passed, 0 known failure, 0 skipped +[inst/parzenwin.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/parzenwin.m +***** assert (parzenwin (1), 1) +***** assert (parzenwin (2), 0.25 * ones (2, 1)) +***** error parzenwin () +***** error parzenwin (0.5) +***** error parzenwin (-1) +***** error parzenwin (ones (1, 4)) +***** error parzenwin (1, 2) +7 tests, 7 passed, 0 known failure, 0 skipped +[inst/data2fun.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/data2fun.m +***** shared t, y + t = linspace (0, 1, 10); + y = t.^2 - 2*t + 1; +***** test + fhandle = data2fun (t, y); + assert (y, fhandle (t)); +***** test + unwind_protect + # Change to temporary folder in case tester cannot write current folder + olddir = pwd(); + cd(tempdir()); + + [fhandle fname] = data2fun (t, y, "file", "testdata2fun"); + yt = testdata2fun (t); + assert (y, yt); + assert (y, fhandle (t)); + unwind_protect_cleanup + unlink (fname); + unlink ([fname(1:end-2) ".mat"]); + cd(olddir) + end_unwind_protect +***** test + unwind_protect + # Change to temporary folder in case tester cannot write current folder + olddir = pwd(); + cd(tempdir()); + + [fhandle fname] = data2fun (t, y, "file", ""); + # generate commmand to execute using random file name + cmd = sprintf ("yt = %s(t);", nthargout (2, @fileparts, fname)); + eval (cmd); + assert (y, yt); + assert (y, fhandle (t)); + unwind_protect_cleanup + unlink (fname); + unlink ([fname(1:end-2) ".mat"]); + cd(olddir) + end_unwind_protect +***** test + unwind_protect + # Change to temporary folder in case tester cannot write current folder + olddir = pwd(); + cd(tempdir()); + [fhandle fname] = data2fun (t, y, "file", "testdata2fun", "interp", "linear"); + yt = testdata2fun (t); + assert (y, yt); + assert (y, fhandle (t)); + unwind_protect_cleanup + unlink (fname); + unlink ([fname(1:end-2) ".mat"]); + cd(olddir) + end_unwind_protect +***** error data2fun () +***** error data2fun (1) +***** error data2fun (1, 2, "file") +7 tests, 7 passed, 0 known failure, 0 skipped +[inst/residued.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/residued.m +***** test + B=1; A=[1 -1]; + [r,p,f,m] = residued(B,A); + assert({r,p,f,m},{1,1,[],1},100*eps); + [r2,p2,f2,m2] = residuez(B,A); + assert({r,p,f,m},{r2,p2,f2,m2},100*eps); +***** test + B=[1 -2 1]; A=[1 -1]; + [r,p,f,m] = residued(B,A); + assert({r,p,f,m},{0,1,[1 -1],1},100*eps); +***** test + B=[1 -2 1]; A=[1 -0.5]; + [r,p,f,m] = residued(B,A); + assert({r,p,f,m},{0.25,0.5,[1 -1.5],1},100*eps); +***** test + B=1; A=[1 -0.75 0.125]; + [r,p,f,m] = residued(B,A); + [r2,p2,f2,m2] = residuez(B,A); + assert({r,p,f,m},{r2,p2,f2,m2},100*eps); +***** test + B=1; A=[1 -2 1]; + [r,p,f,m] = residued(B,A); + [r2,p2,f2,m2] = residuez(B,A); + assert({r,p,f,m},{r2,p2,f2,m2},100*eps); +***** test + B=[6,2]; A=[1 -2 1]; + [r,p,f,m] = residued(B,A); + [r2,p2,f2,m2] = residuez(B,A); + assert({r,p,f,m},{r2,p2,f2,m2},100*eps); +***** test + B=[1 1 1]; A=[1 -2 1]; + [r,p,f,m] = residued(B,A); + assert(r,[0;3],1e-7); + assert(p,[1;1],1e-8); + assert(f,1,100*eps); + assert(m,[1;2],100*eps); +***** test + B=[2 6 6 2]; A=[1 -2 1]; + [r,p,f,m] = residued(B,A); + assert(r,[8;16],3e-7); + assert(p,[1;1],1e-8); + assert(f,[2,10],100*eps); + assert(m,[1;2],100*eps); +***** test + B=[1,6,2]; A=[1 -2 1]; + [r,p,f,m] = residued(B,A); + assert(r,[-1;9],3e-7); + assert(p,[1;1],1e-8); + assert(f,1,100*eps); + assert(m,[1;2],100*eps); +***** test + B=[1 0 0 0 1]; A=[1 0 0 0 -1]; + [r,p,f,m] = residued(B,A); + [~,is] = sort(angle(p)); + assert(r(is),[-1/2;-j/2;1/2;j/2],100*eps); + assert(p(is),[-1;-j;1;j],100*eps); + assert(f,1,100*eps); + assert(m,[1;1;1;1],100*eps); +10 tests, 10 passed, 0 known failure, 0 skipped +[inst/ellipord.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/ellipord.m ***** demo fs = 44100; - Npts = fs / 2; + Npts = fs; fpass = 4000; - fstop = 10987; - Rpass = 1; - Rstop = 26; - Wpass = 2 / fs * fpass; - Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) - [b, a] = butter (n, Wn_p); - f = 8000:12000; - W = 2 * pi * f; - [H, f] = freqz (b, a, Npts, fs); + fstop = 13713; + Rpass = 3; + Rstop = 40; + Wpass = 2/fs * fpass; + Wstop = 2/fs * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) + [b, a] = ellip (n, Rpass, Rstop, Wn); + f = 0:fs/2; + W = f * (2 * pi / fs); + H = freqz (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Digital Butterworth low-pass : matching pass band"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; outline_lp_pass_x = [f(2) , fpass(1), fpass(1)]; outline_lp_pass_y = [-Rpass, -Rpass , -80]; outline_lp_stop_x = [f(2) , fstop(1), fstop(1), max(f)]; outline_lp_stop_y = [0 , 0 , -Rstop , -Rstop]; - hold on; - plot (outline_lp_pass_x, outline_lp_pass_y, "m"); - plot (outline_lp_stop_x, outline_lp_stop_y, "m"); + hold on + plot (outline_lp_pass_x, outline_lp_pass_y, "m", outline_lp_stop_x, outline_lp_stop_y, "m"); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("2nd order digital elliptical low-pass (without margin)"); ***** demo fs = 44100; - Npts = fs / 2; + Npts = fs; fpass = 4000; - fstop = 10987; - Rpass = 1; - Rstop = 26; - Wpass = 2 / fs * fpass; - Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) - [b, a] = butter (n, Wn_s); - f = 8000:12000; - W = 2 * pi * f; - [H, f] = freqz (b, a, Npts, fs); + fstop = 13712; + Rpass = 3; + Rstop = 40; + Wpass = 2/fs * fpass; + Wstop = 2/fs * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) + [b, a] = ellip (n, Rpass, Rstop, Wn); + f = 0:fs/2; + W = f * (2 * pi / fs); + H = freqz (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Digital Butterworth low-pass : matching stop band"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; outline_lp_pass_x = [f(2) , fpass(1), fpass(1)]; outline_lp_pass_y = [-Rpass, -Rpass , -80]; outline_lp_stop_x = [f(2) , fstop(1), fstop(1), max(f)]; outline_lp_stop_y = [0 , 0 , -Rstop , -Rstop]; - hold on; - plot (outline_lp_pass_x, outline_lp_pass_y, "m"); - plot (outline_lp_stop_x, outline_lp_stop_y, "m"); + hold on + plot (outline_lp_pass_x, outline_lp_pass_y, "m", outline_lp_stop_x, outline_lp_stop_y, "m"); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("3rd order digital elliptical low-pass (just exceeds 2nd order i.e. large margin)"); ***** demo fs = 44100; - Npts = fs / 2; + Npts = fs; fstop = 4000; - fpass = 10987; - Rpass = 1; - Rstop = 26; - Wpass = 2 / fs * fpass; - Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) - [b, a] = butter (n, Wn_p, "high"); - f = 8000:12000; - W = 2 * pi * f; - [H, f] = freqz (b, a, Npts, fs); + fpass = 13713; + Rpass = 3; + Rstop = 40; + Wpass = 2/fs * fpass; + Wstop = 2/fs * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) + [b, a] = ellip (n, Rpass, Rstop, Wn, "high"); + f = 0:fs/2; + W = f * (2 * pi / fs); + H = freqz (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Digital Butterworth high-pass : matching pass band"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; outline_hp_pass_x = [fpass(1), fpass(1), max(f)]; outline_hp_pass_y = [-80 , -Rpass , -Rpass]; outline_hp_stop_x = [min(f) , fstop(1), fstop(1), max(f)]; outline_hp_stop_y = [-Rstop , -Rstop , 0 , 0 ]; - hold on; - plot (outline_hp_pass_x, outline_hp_pass_y, "m"); - plot (outline_hp_stop_x, outline_hp_stop_y, "m"); + hold on + plot (outline_hp_pass_x, outline_hp_pass_y, "m", outline_hp_stop_x, outline_hp_stop_y, "m"); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("2nd order digital elliptical high-pass (without margin)"); ***** demo fs = 44100; - Npts = fs / 2; + Npts = fs; fstop = 4000; - fpass = 10987; - Rpass = 1; - Rstop = 26; - Wpass = 2 / fs * fpass; - Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) - [b, a] = butter (n, Wn_s, "high"); - f = 8000:12000; - W = 2 * pi * f; - [H, f] = freqz (b, a, Npts, fs); - plot (f, 20 * log10 (abs (H))) - title ("Digital Butterworth high-pass : matching stop band"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + fpass = 13712; + Rpass = 3; + Rstop = 40; + Wpass = 2/fs * fpass; + Wstop = 2/fs * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) + [b, a] = ellip (n, Rpass, Rstop, Wn, "high"); + f = 0:fs/2; + W = f * (2 * pi / fs); + H = freqz (b, a, W); + plot (f, 20 * log10 (abs (H))); outline_hp_pass_x = [fpass(1), fpass(1), max(f)]; outline_hp_pass_y = [-80 , -Rpass , -Rpass]; outline_hp_stop_x = [min(f) , fstop(1), fstop(1), max(f)]; outline_hp_stop_y = [-Rstop , -Rstop , 0 , 0 ]; - hold on; - plot (outline_hp_pass_x, outline_hp_pass_y, "m"); - plot (outline_hp_stop_x, outline_hp_stop_y, "m"); + hold on + plot (outline_hp_pass_x, outline_hp_pass_y, "m", outline_hp_stop_x, outline_hp_stop_y, "m"); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("3rd order digital elliptical high-pass (just exceeds 2nd order i.e. large margin)"); ***** demo fs = 44100; + Npts = fs; fpass = [9500 9750]; - fstop = [8500 10051]; - Rpass = 1; - Rstop = 26; - Wpass = 2 / fs * fpass; - Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) - [b, a] = butter (n, Wn_p); - f = (8000:12000)'; + fstop = [8500 10261]; + Rpass = 3; + Rstop = 40; + Wpass = 2/fs * fpass; + Wstop = 2/fs * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) + [b, a] = ellip (n, Rpass, Rstop, Wn); + f = 5000:15000; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Digital Butterworth band-pass : matching pass band, limit on upper freq"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + plot (f, 20 * log10 (abs (H))) outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... - -Rstop , -Rstop]; - hold on; - plot (outline_bp_pass_x, outline_bp_pass_y, "m"); - plot (outline_bp_stop_x, outline_bp_stop_y, "m"); + outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; + hold on + plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("4th order digital elliptical band-pass (without margin) limitation on upper freq"); ***** demo fs = 44100; + Npts = fs; fpass = [9500 9750]; - fstop = [8500 10051]; - Rpass = 1; - Rstop = 26; - Wpass = 2 / fs * fpass; - Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) - [b, a] = butter (n, Wn_s); - f = (8000:12000)'; + fstop = [9000 10700]; + Rpass = 3; + Rstop = 40; + Wpass = 2/fs * fpass; + Wstop = 2/fs * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) + [b, a] = ellip (n, Rpass, Rstop, Wn); + f = 5000:15000; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Digital Butterworth band-pass : matching stop band, limit on upper freq"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + plot (f, 20 * log10 (abs (H))) outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... - -Rstop , -Rstop]; - hold on; - plot (outline_bp_pass_x, outline_bp_pass_y, "m"); - plot (outline_bp_stop_x, outline_bp_stop_y, "m"); + outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; + hold on + plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("4th order digital elliptical band-pass (without margin) limitation on lower freq"); ***** demo fs = 44100; + Npts = fs; fpass = [9500 9750]; - fstop = [9204 10700]; - Rpass = 1; - Rstop = 26; - Wpass = 2 / fs * fpass; - Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) - [b, a] = butter (n, Wn_p); - f = (8000:12000)'; + fstop = [8500 10260]; + Rpass = 3; + Rstop = 40; + Wpass = 2/fs * fpass; + Wstop = 2/fs * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) + [b, a] = ellip (n, Rpass, Rstop, Wn); + f = 5000:15000; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Digital Butterworth band-pass : matching pass band, limit on lower freq"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + plot (f, 20 * log10 (abs (H))) outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... - -Rstop , -Rstop]; - hold on; - plot (outline_bp_pass_x, outline_bp_pass_y, "m"); - plot (outline_bp_stop_x, outline_bp_stop_y, "m"); + outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; + hold on + plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("6th order digital elliptical band-pass (just exceeds 4th order i.e. large margin) limitation on upper freq"); ***** demo fs = 44100; + Npts = fs; fpass = [9500 9750]; - fstop = [9204 10700]; - Rpass = 1; - Rstop = 26; - Wpass = 2 / fs * fpass; - Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) - [b, a] = butter (n, Wn_s); - f = (8000:12000)'; + fstop = [9001 10700]; + Rpass = 3; + Rstop = 40; + Wpass = 2/fs * fpass; + Wstop = 2/fs * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) + [b, a] = ellip (n, Rpass, Rstop, Wn); + f = 5000:15000; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Digital Butterworth band-pass : matching stop band, limit on lower freq"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + plot (f, 20 * log10 (abs (H))) outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... - -Rstop , -Rstop]; - hold on; - plot (outline_bp_pass_x, outline_bp_pass_y, "m"); - plot (outline_bp_stop_x, outline_bp_stop_y, "m"); + outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; + hold on + plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("6th order digital elliptical band-pass (just exceeds 4th order i.e. large margin) limitation on lower freq"); ***** demo fs = 44100; - fstop = [9875, 10126.5823]; - fpass = [8500 10833]; + Npts = fs; + fstop = [9875 10126.5823]; + fpass = [8500 11073]; Rpass = 0.5; Rstop = 40; - Wpass = 2 / fs * fpass; - Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) - [b, a] = butter (n, Wn_p, "stop"); - f = (8000:12000)'; + Wpass = 2/fs * fpass; + Wstop = 2/fs * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) + [b, a] = ellip (n, Rpass, Rstop, Wn, "stop"); + f = 5000:15000; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Digital Butterworth notch : matching pass band, limit on upper freq"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + plot (f, 20 * log10 (abs (H))) outline_notch_pass_x_a = [min(f) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... - 0 , 0 ]; - hold on; - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); - plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); - plot (outline_notch_stop_x, outline_notch_stop_y, "m"); + outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; + hold on + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("4th order digital elliptical notch (without margin) limit on upper freq"); ***** demo fs = 44100; - fstop = [9875, 10126.5823]; - fpass = [8500 10833]; + Npts = fs; + fstop = [9875 10126.5823]; + fpass = [8952 12000]; Rpass = 0.5; Rstop = 40; - Wpass = 2 / fs * fpass; - Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) - [b, a] = butter (n, Wn_s, "stop"); - f = (8000:12000)'; + Wpass = 2/fs * fpass; + Wstop = 2/fs * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) + [b, a] = ellip (n, Rpass, Rstop, Wn, "stop"); + f = 5000:15000; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Digital Butterworth notch : matching stop band, limit on upper freq"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + plot (f, 20 * log10 (abs (H))) outline_notch_pass_x_a = [min(f) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... - 0 , 0 ]; - hold on; - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); - plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); - plot (outline_notch_stop_x, outline_notch_stop_y, "m"); + outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; + hold on + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("4th order digital elliptical notch (without margin) limit on lower freq"); ***** demo fs = 44100; - fstop = [9875, 10126.5823]; - fpass = [9183 11000]; + Npts = fs; + fstop = [9875 10126.5823]; + fpass = [8500 11072]; Rpass = 0.5; Rstop = 40; - Wpass = 2 / fs * fpass; - Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) - [b, a] = butter (n, Wn_p, "stop"); - f = (8000:12000)'; + Wpass = 2/fs * fpass; + Wstop = 2/fs * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) + [b, a] = ellip (n, Rpass, Rstop, Wn, "stop"); + f = 5000:15000; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Digital Butterworth notch : matching pass band, limit on lower freq"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + plot (f, 20 * log10 (abs (H))) outline_notch_pass_x_a = [min(f) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... - 0 , 0 ]; - hold on; - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); - plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); - plot (outline_notch_stop_x, outline_notch_stop_y, "m"); + outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; + hold on + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("6th order digital elliptical notch (just exceeds 4th order) limit on upper freq"); ***** demo fs = 44100; - fstop = [9875, 10126.5823]; - fpass = [9183 11000]; + Npts = fs; + fstop = [9875 10126.5823]; + fpass = [8953 12000]; Rpass = 0.5; Rstop = 40; - Wpass = 2 / fs * fpass; - Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) - [b, a] = butter (n, Wn_s, "stop"); - f = (8000:12000)'; + Wpass = 2/fs * fpass; + Wstop = 2/fs * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) + [b, a] = ellip (n, Rpass, Rstop, Wn, "stop"); + f = 5000:15000; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Digital Butterworth notch : matching stop band, limit on lower freq"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + plot (f, 20 * log10 (abs (H))) outline_notch_pass_x_a = [min(f) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... - 0 , 0 ]; - hold on; - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); - plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); - plot (outline_notch_stop_x, outline_notch_stop_y, "m"); + outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; + hold on + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("6th order digital elliptical notch (just exceeds 4th order) limit on lower freq"); ***** demo fpass = 4000; - fstop = 13583; - Rpass = 1; - Rstop = 26; - Wpass = 2 * pi * fpass; - Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = butter (n, Wn_p, "s"); + fstop = 20224; + Rpass = 3; + Rstop = 40; + Wpass = 2*pi * fpass; + Wstop = 2*pi * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = ellip (n, Rpass, Rstop, Wn, "s"); f = 1000:10:100000; - W = 2 * pi * f; + W = 2*pi * f; H = freqs (b, a, W); - semilogx (f, 20 * log10 (abs (H))) - title ("Analog Butterworth low-pass : matching pass band"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + semilogx(f, 20 * log10 (abs (H))) outline_lp_pass_x = [f(2) , fpass(1), fpass(1)]; outline_lp_pass_y = [-Rpass, -Rpass , -80]; outline_lp_stop_x = [f(2) , fstop(1), fstop(1), max(f)]; outline_lp_stop_y = [0 , 0 , -Rstop , -Rstop]; - hold on; - plot (outline_lp_pass_x, outline_lp_pass_y, "m"); - plot (outline_lp_stop_x, outline_lp_stop_y, "m"); + hold on + plot (outline_lp_pass_x, outline_lp_pass_y, "m", outline_lp_stop_x, outline_lp_stop_y, "m") ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("2nd order analog elliptical low-pass (without margin)"); ***** demo fpass = 4000; - fstop = 13583; - Rpass = 1; - Rstop = 26; - Wpass = 2 * pi * fpass; - Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = butter (n, Wn_s, "s"); + fstop = 20223; + Rpass = 3; + Rstop = 40; + Wpass = 2*pi * fpass; + Wstop = 2*pi * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = ellip (n, Rpass, Rstop, Wn, "s"); f = 1000:10:100000; - W = 2 * pi * f; + W = 2*pi * f; H = freqs (b, a, W); - semilogx (f, 20 * log10 (abs (H))); - title ("Analog Butterworth low-pass : matching stop band"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + semilogx (f, 20 * log10 (abs (H))) outline_lp_pass_x = [f(2) , fpass(1), fpass(1)]; outline_lp_pass_y = [-Rpass, -Rpass , -80]; outline_lp_stop_x = [f(2) , fstop(1), fstop(1), max(f)]; outline_lp_stop_y = [0 , 0 , -Rstop , -Rstop]; - hold on; - plot (outline_lp_pass_x, outline_lp_pass_y, "m"); - plot (outline_lp_stop_x, outline_lp_stop_y, "m"); + hold on + plot (outline_lp_pass_x, outline_lp_pass_y, "m", outline_lp_stop_x, outline_lp_stop_y, "m") ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("3rd order analog elliptical low-pass (just exceeds 2nd order i.e. large margin)"); ***** demo fstop = 4000; - fpass = 13583; - Rpass = 1; - Rstop = 26; - Wpass = 2 * pi * fpass; - Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = butter (n, Wn_p, "high", "s"); + fpass = 20224; + Rpass = 3; + Rstop = 40; + Wpass = 2*pi * fpass; + Wstop = 2*pi * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = ellip (n, Rpass, Rstop, Wn, "high", "s"); f = 1000:10:100000; - W = 2 * pi * f; + W = 2*pi * f; H = freqs (b, a, W); - semilogx (f, 20 * log10 (abs (H))); - title ("Analog Butterworth high-pass : matching pass band"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + semilogx (f, 20 * log10 (abs (H))) outline_hp_pass_x = [fpass(1), fpass(1), max(f)]; outline_hp_pass_y = [-80 , -Rpass , -Rpass]; outline_hp_stop_x = [f(2) , fstop(1), fstop(1), max(f)]; outline_hp_stop_y = [-Rstop , -Rstop , 0 , 0 ]; - hold on; - plot (outline_hp_pass_x, outline_hp_pass_y, "m"); - plot (outline_hp_stop_x, outline_hp_stop_y, "m"); + hold on + plot (outline_hp_pass_x, outline_hp_pass_y, "m", outline_hp_stop_x, outline_hp_stop_y, "m") ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("2nd order analog elliptical high-pass (without margin)"); ***** demo fstop = 4000; - fpass = 13583; - Rpass = 1; - Rstop = 26; - Wpass = 2 * pi * fpass; - Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = butter (n, Wn_s, "high", "s"); + fpass = 20223; + Rpass = 3; + Rstop = 40; + Wpass = 2*pi * fpass; + Wstop = 2*pi * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = ellip (n, Rpass, Rstop, Wn, "high", "s"); f = 1000:10:100000; - W = 2 * pi * f; + W = 2*pi * f; H = freqs (b, a, W); - semilogx (f, 20 * log10 (abs (H))); - title ("Analog Butterworth high-pass : matching stop band"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + semilogx (f, 20 * log10 (abs (H))) outline_hp_pass_x = [fpass(1), fpass(1), max(f)]; outline_hp_pass_y = [-80 , -Rpass , -Rpass]; outline_hp_stop_x = [f(2) , fstop(1), fstop(1), max(f)]; outline_hp_stop_y = [-Rstop , -Rstop , 0 , 0 ]; - hold on; - plot (outline_hp_pass_x, outline_hp_pass_y, "m"); - plot (outline_hp_stop_x, outline_hp_stop_y, "m"); + hold on + plot (outline_hp_pass_x, outline_hp_pass_y, "m", outline_hp_stop_x, outline_hp_stop_y, "m") ylim ([-80, 0]); -***** demo - fpass = [9875, 10126.5823]; - fstop = [9000, 10436]; - Rpass = 1; - Rstop = 26; - Wpass = 2 * pi * fpass; - Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = butter (n, Wn_p, "s"); - f = 8000:12000; - W = 2 * pi * f; - H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Analog Butterworth band-pass : matching pass band, limit on upper freq"); + grid on xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); - grid on; + title ("3rd order analog elliptical high-pass (just exceeds 2nd order i.e. large margin)"); +***** demo + fpass = [9875 10126.5823]; + fstop = [9000 10657]; + Rpass = 3; + Rstop = 40; + fcenter = sqrt (fpass(1) * fpass(2)); + Wpass = 2*pi * fpass; + Wstop = 2*pi * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = ellip (n, Rpass, Rstop, Wn, "s"); + f = 5000:15000; + W = 2*pi * f; + H = freqs (b, a, W); + plot (f, 20 * log10 (abs (H))) outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... - -Rstop , -Rstop]; - hold on; - plot (outline_bp_pass_x, outline_bp_pass_y, "m"); - plot (outline_bp_stop_x, outline_bp_stop_y, "m"); + outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; + hold on + plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); -***** demo - fpass = [9875, 10126.5823]; - fstop = [9000, 10436]; - Rpass = 1; - Rstop = 26; - Wpass = 2 * pi * fpass; - Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = butter (n, Wn_s, "s"); - f = 8000:12000; - W = 2 * pi * f; - H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Analog Butterworth band-pass : matching stop band, limit on upper freq"); + grid on xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); - grid on; + title ("4th order analog elliptical band-pass (without margin) limitation on upper freq"); +***** demo + fpass = [9875 10126.5823]; + fstop = [9384 12000]; + Rpass = 3; + Rstop = 40; + fcenter = sqrt (fpass(1) * fpass(2)); + Wpass = 2*pi * fpass; + Wstop = 2*pi * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = ellip (n, Rpass, Rstop, Wn, "s"); + f = 5000:15000; + W = 2*pi * f; + H = freqs (b, a, W); + plot (f, 20 * log10 (abs (H))) outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... - -Rstop , -Rstop]; - hold on; - plot (outline_bp_pass_x, outline_bp_pass_y, "m"); - plot (outline_bp_stop_x, outline_bp_stop_y, "m"); + outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; + hold on + plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); -***** demo - fpass = [9875, 10126.5823]; - fstop = [9582, 11000]; - Rpass = 1; - Rstop = 26; - Wpass = 2 * pi * fpass; - Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = butter (n, Wn_p, "s"); - f = 8000:12000; - W = 2 * pi * f; - H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Analog Butterworth band-pass : matching pass band, limit on lower freq"); + grid on xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); - grid on; + title ("4th order analog elliptical band-pass (without margin) limitation on lower freq"); +***** demo + fpass = [9875 10126.5823]; + fstop = [9000 10656]; + Rpass = 3; + Rstop = 40; + fcenter = sqrt (fpass(1) * fpass(2)); + Wpass = 2*pi * fpass; + Wstop = 2*pi * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = ellip (n, Rpass, Rstop, Wn, "s"); + f = 5000:15000; + W = 2*pi * f; + H = freqs (b, a, W); + plot (f, 20 * log10 (abs (H))) outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... - -Rstop , -Rstop]; - hold on; - plot (outline_bp_pass_x, outline_bp_pass_y, "m"); - plot (outline_bp_stop_x, outline_bp_stop_y, "m"); + outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; + hold on + plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); -***** demo - fpass = [9875, 10126.5823]; - fstop = [9582, 11000]; - Rpass = 1; - Rstop = 26; - Wpass = 2 * pi * fpass; - Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = butter (n, Wn_s, "s"); - f = 8000:12000; - W = 2 * pi * f; - H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Analog Butterworth band-pass : matching stop band, limit on lower freq"); + grid on xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); - grid on; + title ("6th order analog elliptical band-pass (just exceeds 4th order i.e. large margin) limitation on upper freq"); +***** demo + fpass = [9875 10126.5823]; + fstop = [9385 12000]; + Rpass = 3; + Rstop = 40; + fcenter = sqrt (fpass(1) * fpass(2)); + Wpass = 2*pi * fpass; + Wstop = 2*pi * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = ellip (n, Rpass, Rstop, Wn, "s"); + f = 5000:15000; + W = 2*pi * f; + H = freqs (b, a, W); + plot (f, 20 * log10 (abs (H))) outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... - -Rstop , -Rstop]; - hold on; - plot (outline_bp_pass_x, outline_bp_pass_y, "m"); - plot (outline_bp_stop_x, outline_bp_stop_y, "m"); + outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; + hold on + plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("6th order analog elliptical band-pass (just exceeds 4th order i.e. large margin) limitation on lower freq"); ***** demo fstop = [9875 10126.5823]; - fpass = [9000 10436]; - Rpass = 1; - Rstop = 26; - Wpass = 2 * pi * fpass; - Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = butter (n, Wn_p, "stop", "s"); - f = 8000:12000; - W = 2 * pi * f; + fpass = [9000 10657]; + Rpass = 3; + Rstop = 40; + fcenter = sqrt (fpass(1) * fpass(2)); + Wpass = 2*pi * fpass; + Wstop = 2*pi * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = ellip (n, Rpass, Rstop, Wn, "stop", "s"); + f = 5000:15000; + W = 2*pi * f; H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Analog Butterworth notch : matching pass band, limit on upper freq"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + plot (f, 20 * log10 (abs (H))) outline_notch_pass_x_a = [f(2) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... - 0 , 0 ]; - hold on; - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); - plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); - plot (outline_notch_stop_x, outline_notch_stop_y, "m"); + outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; + hold on + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("4th order analog elliptical notch (without margin) limit on upper freq"); ***** demo fstop = [9875 10126.5823]; - fpass = [9000 10436]; - Rpass = 1; - Rstop = 26; - Wpass = 2 * pi * fpass; - Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = butter (n, Wn_s, "stop", "s"); - f = 8000:12000; - W = 2 * pi * f; + fpass = [9384 12000]; + Rpass = 3; + Rstop = 40; + fcenter = sqrt (fpass(1) * fpass(2)); + Wpass = 2*pi * fpass; + Wstop = 2*pi * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = ellip (n, Rpass, Rstop, Wn, "stop", "s"); + f = 5000:15000; + W = 2*pi * f; H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Analog Butterworth notch : matching stop band, limit on upper freq"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + plot (f, 20 * log10 (abs (H))) outline_notch_pass_x_a = [f(2) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... - 0 , 0 ]; - hold on; - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); - plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); - plot (outline_notch_stop_x, outline_notch_stop_y, "m"); + outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; + hold on + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("4th order analog elliptical notch (without margin) limit on lower freq"); ***** demo fstop = [9875 10126.5823]; - fpass = [9582 11000]; - Rpass = 1; - Rstop = 26; - Wpass = 2 * pi * fpass; - Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = butter (n, Wn_p, "stop", "s"); - f = 8000:12000; - W = 2 * pi * f; + fpass = [9000 10656]; + Rpass = 3; + Rstop = 40; + fcenter = sqrt (fpass(1) * fpass(2)); + Wpass = 2*pi * fpass; + Wstop = 2*pi * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = ellip (n, Rpass, Rstop, Wn, "stop", "s"); + f = 5000:15000; + W = 2*pi * f; H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Analog Butterworth notch : matching pass band, limit on lower freq"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + plot (f, 20 * log10 (abs (H))) outline_notch_pass_x_a = [f(2) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... - 0 , 0 ]; - hold on; - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); - plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); - plot (outline_notch_stop_x, outline_notch_stop_y, "m"); + outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; + hold on + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("6th order analog elliptical notch (just exceeds 4th order) limit on upper freq"); ***** demo fstop = [9875 10126.5823]; - fpass = [9582 11000]; - Rpass = 1; - Rstop = 26; - Wpass = 2 * pi * fpass; - Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = butter (n, Wn_s, "stop", "s"); - f = 8000:12000; - W = 2 * pi * f; + fpass = [9385 12000]; + Rpass = 3; + Rstop = 40; + fcenter = sqrt (fpass(1) * fpass(2)); + Wpass = 2*pi * fpass; + Wstop = 2*pi * fstop; + [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = ellip (n, Rpass, Rstop, Wn, "stop", "s"); + f = 5000:15000; + W = 2*pi * f; H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))); - title ("Analog Butterworth notch : matching stop band, limit on lower freq"); - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - grid on; + plot (f, 20 * log10 (abs (H))) outline_notch_pass_x_a = [f(2) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... - fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... - 0 , 0 ]; - hold on; - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); - plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); - plot (outline_notch_stop_x, outline_notch_stop_y, "m"); + outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; + hold on + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") + xlim ([f(1), f(end)]); ylim ([-80, 0]); + grid on + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + title ("6th order analog elliptical notch (just exceeds 4th order) limit on lower freq"); ***** test # Analog band-pass - [n, Wn_p, Wn_s] = buttord (2 * pi * [9875, 10126.5823], ... - 2 * pi * [9000, 10436], 1, 26, "s"); - assert (n, 4); - assert (round (Wn_p), [61903, 63775]); - assert (round (Wn_s), [61575, 64114]); + [n, Wn] = ellipord (2 * pi * [9875, 10126.5823], ... + 2 * pi * [9000, 10657], 3, 40, "s"); + assert (n, 2); + assert (round (Wn), [62046, 63627]); ***** test # Analog band-pass - [n, Wn_p, Wn_s] = buttord (2 * pi * [9875, 10126.5823], ... - 2 * pi * [9582, 11000], 1, 26, "s"); - assert (n, 4); - assert (round (Wn_p), [61903, 63775]); - assert (round (Wn_s), [61575, 64115]); + [n, Wn] = ellipord (2 * pi * [9875, 10126.5823], ... + 2 * pi * [9384, 12000], 3, 40, "s"); + assert (n, 2); + assert (round (Wn), [62046, 63627]); ***** test # Analog band-pass - [n, Wn_p, Wn_s] = buttord (2 * pi * [9875, 10126.5823], ... - 2 * pi * [9000, 10437], 1, 26, "s"); + [n, Wn] = ellipord (2 * pi * [9875, 10126.5823], ... + 2 * pi * [9000, 10656], 3, 40, "s"); assert (n, 3); - assert (round (Wn_p), [61850, 63830]); - assert (round (Wn_s), [61848, 63831]); + assert (round (Wn), [62046, 63627]); ***** test # Analog band-pass - [n, Wn_p, Wn_s] = buttord (2 * pi * [9875, 10126.5823], ... - 2 * pi * [9581, 11000], 1, 26, "s"); + [n, Wn] = ellipord (2 * pi * [9875, 10126.5823], ... + 2 * pi * [9385, 12000], 3, 40, "s"); assert (n, 3); - assert (round (Wn_p), [61850, 63830]); - assert (round (Wn_s), [61847, 63832]); + assert (round (Wn), [62046, 63627]); ***** test # Analog high-pass - [n, Wn_p, Wn_s] = buttord (2 * pi * 13583, 2 * pi * 4000, 1, 26, "s"); - assert (n, 4); - assert (round (Wn_p), 72081); - assert (round (Wn_s), 53101); + [n, Wn] = ellipord (2 * pi * 20224, 2 * pi * 4000, 3, 40, "s"); + assert (n, 2); + assert (round (Wn), 127071); ***** test # Analog high-pass - [n, Wn_p, Wn_s] = buttord (2 * pi * 13584, 2 * pi * 4000, 1, 26, "s"); + [n, Wn] = ellipord (2 * pi * 20223, 2 * pi * 4000, 3, 40, "s"); assert (n, 3); - assert (round (Wn_p), 68140); - assert (round (Wn_s), 68138); + assert (round (Wn), 127065); ***** test # Analog low-pass - [n, Wn_p, Wn_s] = buttord (2 * pi * 4000, 2 * pi * 13583, 1, 26, "s"); - assert (n, 4); - assert (round (Wn_p), 29757); - assert (round (Wn_s), 40394); + [n, Wn] = ellipord (2 * pi * 4000, 2 * pi * 20224, 3, 40, "s"); + assert (n, 2); + assert (round (Wn), 25133); ***** test # Analog low-pass - [n, Wn_p, Wn_s] = buttord (2 * pi * 4000, 2 * pi * 13584, 1, 26, "s"); + [n, Wn] = ellipord (2 * pi * 4000, 2 * pi * 20223, 3, 40, "s"); assert (n, 3); - assert (round (Wn_p), 31481); - assert (round (Wn_s), 31482); + assert (round (Wn), 25133); ***** test # Analog notch (narrow band-stop) - [n, Wn_p, Wn_s] = buttord (2 * pi * [9000, 10436], ... - 2 * pi * [9875, 10126.5823], 1, 26, "s"); - assert (n, 4); - assert (round (Wn_p), [60607, 65138]); - assert (round (Wn_s), [61184, 64524]); + [n, Wn] = ellipord (2 * pi * [9000, 10657], ... + 2 * pi * [9875, 10126.5823], 3, 40, "s"); + assert (n, 2); + assert (round (Wn), [58958, 66960]); ***** test # Analog notch (narrow band-stop) - [n, Wn_p, Wn_s] = buttord (2 * pi * [9582, 11000], ... - 2 * pi * [9875, 10126.5823], 1, 26, "s"); - assert (n, 4); - assert (round (Wn_p), [60606, 65139]); - assert (round (Wn_s), [61184, 64524]); + [n, Wn] = ellipord (2 * pi * [9384, 12000], ... + 2 * pi * [9875, 10126.5823], 3, 40, "s"); + assert (n, 2); + assert (round (Wn), [58961 , 66956]); ***** test # Analog notch (narrow band-stop) - [n, Wn_p, Wn_s] = buttord (2 * pi * [9000, 10437], ... - 2 * pi * [9875, 10126.5823], 1, 26, "s"); + [n, Wn] = ellipord (2 * pi * [9000, 10656], ... + 2 * pi * [9875, 10126.5823], 3, 40, "s"); assert (n, 3); - assert (round (Wn_p), [60722, 65015]); - assert (round (Wn_s), [60726, 65011]); + assert (round (Wn), [58964, 66954]); ***** test # Analog notch (narrow band-stop) - [n, Wn_p, Wn_s] = buttord (2 * pi * [9581, 11000], ... - 2 * pi * [9875, 10126.5823], 1, 26, "s"); + [n, Wn] = ellipord (2 * pi * [9385, 12000], ... + 2 * pi * [9875, 10126.5823], 3, 40, "s"); assert (n, 3); - assert (round (Wn_p), [60721, 65016]); - assert (round (Wn_s), [60726, 65011]); + assert (round (Wn), [58968, 66949]); ***** test # Digital band-pass fs = 44100; - [n, Wn_p, Wn_s] = buttord (2 / fs * [9500, 9750], ... - 2 / fs * [8500, 10051], 1, 26); - Wn_p = Wn_p * fs / 2; - Wn_s = Wn_s * fs / 2; - assert (n, 4); - assert (round (Wn_p), [9477, 9773]); - assert (round (Wn_s), [9425, 9826]); + [n, Wn] = ellipord (2 / fs * [9500, 9750], 2 / fs * [8500, 10261], 3, 40); + Wn = Wn * fs / 2; + assert (n, 2); + assert (round (Wn), [9500, 9750]); ***** test # Digital band-pass fs = 44100; - [n, Wn_p, Wn_s] = buttord (2 / fs * [9500, 9750], ... - 2 / fs * [9204, 10700], 1, 26); - Wn_p = Wn_p * fs / 2; - Wn_s = Wn_s * fs / 2; - assert (n, 4); - assert (round (Wn_p), [9477, 9773]); - assert (round (Wn_s), [9425, 9826]); + [n, Wn] = ellipord (2 / fs * [9500, 9750], 2 / fs * [9000, 10700], 3, 40); + Wn = Wn * fs / 2; + assert (n, 2); + assert (round (Wn), [9500, 9750]); ***** test # Digital band-pass fs = 44100; - [n, Wn_p, Wn_s] = buttord (2 / fs * [9500, 9750], ... - 2 / fs * [8500, 10052], 1, 26); - Wn_p = Wn_p * fs / 2; - Wn_s = Wn_s * fs / 2; + [n, Wn] = ellipord (2 / fs * [9500, 9750], 2 / fs * [8500, 10260], 3, 40); + Wn = Wn * fs / 2; assert (n, 3); - assert (round (Wn_p), [9469, 9782]); - assert (round (Wn_s), [9468, 9782]); + assert (round (Wn), [9500, 9750]); ***** test # Digital band-pass fs = 44100; - [n, Wn_p, Wn_s] = buttord (2 / fs * [9500, 9750], ... - 2 / fs * [9203, 10700], 1, 26); - Wn_p = Wn_p * fs / 2; - Wn_s = Wn_s * fs / 2; + [n, Wn] = ellipord (2 / fs * [9500, 9750], 2 / fs * [9001, 10700], 3, 40); + Wn = Wn * fs / 2; assert (n, 3); - assert (round (Wn_p), [9469, 9782]); - assert (round (Wn_s), [9468, 9782]); + assert (round (Wn), [9500, 9750]); ***** test # Digital high-pass fs = 44100; - [n, Wn_p, Wn_s] = buttord (2 / fs * 10987, 2 / fs * 4000, 1, 26); - Wn_p = Wn_p * fs / 2; - Wn_s = Wn_s * fs / 2; - assert (n, 4); - assert (round (Wn_p), 9808); - assert (round (Wn_s), 7780); + [n, Wn] = ellipord (2 / fs * 13713, 2 / fs * 4000, 3, 40); + Wn = Wn * fs / 2; + assert (n, 2); + assert (round (Wn), 13713); ***** test # Digital high-pass fs = 44100; - [n, Wn_p, Wn_s] = buttord (2 / fs * 10988, 2 / fs * 4000, 1, 26); - Wn_p = Wn_p * fs / 2; - Wn_s = Wn_s * fs / 2; + [n, Wn] = ellipord (2 / fs * 13712, 2 / fs * 4000, 3, 40); + Wn = Wn * fs / 2; assert (n, 3); - assert (round (Wn_p), 9421); - assert (round (Wn_s), 9421); + assert (round (Wn), 13712); ***** test # Digital low-pass fs = 44100; - [n, Wn_p, Wn_s] = buttord (2 / fs * 4000, 2 / fs * 10987, 1, 26); - Wn_p = Wn_p * fs / 2; - Wn_s = Wn_s * fs / 2; - assert (n, 4); - assert (round (Wn_p), 4686); - assert (round (Wn_s), 6176); + [n, Wn] = ellipord (2 / fs * 4000, 2 / fs * 13713, 3, 40); + Wn = Wn * fs / 2; + assert (n, 2); + assert (round (Wn), 4000); ***** test # Digital low-pass fs = 44100; - [n, Wn_p, Wn_s] = buttord (2 / fs * 4000, 2 / fs * 10988, 1, 26); - Wn_p = Wn_p * fs / 2; - Wn_s = Wn_s * fs / 2; + [n, Wn] = ellipord (2 / fs * 4000, 2 / fs * 13712, 3, 40); + Wn = Wn * fs / 2; assert (n, 3); - assert (round (Wn_p), 4936); - assert (round (Wn_s), 4936); + assert (round (Wn), 4000); ***** test # Digital notch (narrow band-stop) fs = 44100; - [n, Wn_p, Wn_s] = buttord (2 / fs * [8500, 10833], ... - 2 / fs * [9875, 10126.5823], 0.5, 40); - Wn_p = Wn_p * fs / 2; - Wn_s = Wn_s * fs / 2; - assert (n, 4); - assert (round (Wn_p), [9369, 10640]); - assert (round (Wn_s), [9605, 10400]); + [n, Wn] = ellipord (2 / fs * [8500, 11073], 2 / fs * [9875, 10126.5823], 0.5, 40); + Wn = Wn * fs / 2; + assert (n, 2); + assert (round (Wn), [8952, 11073]); ***** test # Digital notch (narrow band-stop) fs = 44100; - [n, Wn_p, Wn_s] = buttord (2 / fs * [9183, 11000], ... - 2 / fs * [9875, 10126.5823], 0.5, 40); - Wn_p = Wn_p * fs / 2; - Wn_s = Wn_s * fs / 2; - assert (n, 4); - assert (round (Wn_p), [9370, 10640]); - assert (round (Wn_s), [9605, 10400]); + [n, Wn] = ellipord (2 / fs * [8952, 12000], 2 / fs * [9875, 10126.5823], 0.5, 40); + Wn = Wn * fs / 2; + assert (n, 2); + assert (round (Wn), [8952, 11073]); ***** test # Digital notch (narrow band-stop) fs = 44100; - [n, Wn_p, Wn_s] = buttord (2 / fs * [8500, 10834], ... - 2 / fs * [9875, 10126.5823], 0.5, 40); - Wn_p = Wn_p * fs / 2; - Wn_s = Wn_s * fs / 2; + [n, Wn] = ellipord (2 / fs * [8500, 11072], 2 / fs * [9875, 10126.5823], 0.5, 40); + Wn = Wn * fs / 2; assert (n, 3); - assert (round (Wn_p), [9421, 10587]); - assert (round (Wn_s), [9422, 10587]); + assert (round (Wn), [8953, 11072]); ***** test # Digital notch (narrow band-stop) fs = 44100; - [n, Wn_p, Wn_s] = buttord (2 / fs * [9182, 11000], ... - 2 / fs * [9875, 10126.5823], 0.5, 40); - Wn_p = Wn_p * fs / 2; - Wn_s = Wn_s * fs / 2; + [n, Wn] = ellipord (2 / fs * [8953, 12000], 2 / fs * [9875, 10126.5823], 0.5, 40); + Wn = Wn * fs / 2; assert (n, 3); - assert (round (Wn_p), [9421, 10587]); - assert (round (Wn_s), [9422, 10587]); -***** error buttord () -***** error buttord (.1) -***** error buttord (.1, .2) -***** error buttord (.1, .2, 3) -***** error buttord ([.1 .1], [.2 .2], 3, 4) -***** error buttord ([.1 .2], [.5 .6], 3, 4) -***** error buttord ([.1 .5], [.2 .6], 3, 4) + assert (round (Wn), [8953, 11072]); +***** error ellipord () +***** error ellipord (.1) +***** error ellipord (.1, .2) +***** error ellipord (.1, .2, 3) +***** error ellipord ([.1 .1], [.2 .2], 3, 4) +***** error ellipord ([.1 .2], [.5 .6], 3, 4) +***** error ellipord ([.1 .5], [.2 .6], 3, 4) 31 tests, 31 passed, 0 known failure, 0 skipped -[inst/ifht.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/ifht.m -***** assert(ifht(fht(1:4)),[1 2 3 4]) -1 test, 1 passed, 0 known failure, 0 skipped -[inst/isminphase.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/isminphase.m -***** demo - b = [3 1]; - a = [1 .5]; - f = isminphase (b, a) - ## test input validation -***** error n = isminphase () -***** error n = isminphase (1, 1, 1, 1) -***** error n = isminphase (1, 1, 1, 1, 1) -***** error n = isminphase ([1:10]', 1) -***** error n = isminphase (1, [1:10]') -***** error n = isminphase ([1:10]', [1:10]') -***** error n = isminphase (1:10, 1:10, 1:10) -***** error n = isminphase (ones (3), ones (3)) +[inst/buffer.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/buffer.m +***** error (buffer(1:10, 4.1)) +***** assert (buffer(1:10, 4), reshape([1:10,0,0],[4,3])) +***** assert (buffer(1:10, 4, 1), reshape([0:3,3:6,6:9,9,10,0,0],[4,4])) +***** assert (buffer(1:10, 4, 2), reshape ([0,0:2,1:4,3:6,5:8,7:10],[4,5])) +***** assert (buffer(1:10, 4, 3), [0,0,0:7;0,0:8;0:9;1:10]) +***** error (buffer(1:10, 4, 3.1)) +***** error (buffer(1:10, 4, 4)) +***** assert (buffer(1:10, 4, -1), reshape([1:4,6:9],[4,2])) +***** assert (buffer(1:10, 4, -2), reshape([1:4,7:10],[4,2])) +***** assert (buffer(1:10, 4, -3), reshape([1:4,8:10,0],[4,2])) +***** assert (buffer(1:10, 4, 1, 11), reshape([11,1:3,3:6,6:9,9,10,0,0],[4,4])) +***** error (buffer(1:10, 4, 1, [10,11])) +***** assert (buffer(1:10, 4, 1, 'nodelay'), reshape([1:4,4:7,7:10],[4,3])) +***** error (buffer(1:10, 4, 1, 'badstring')) +***** assert (buffer(1:10, 4, 2,'nodelay'), reshape ([1:4,3:6,5:8,7:10],[4,4])) +***** assert (buffer(1:10, 4, 3, [11,12,13]),[11,12,13,1:7;12,13,1:8;13,1:9;1:10]) +***** assert (buffer(1:10, 4, 3, 'nodelay'),[1:8;2:9;3:10;4:10,0]) +***** assert (buffer(1:11,4,-2,1),reshape([2:5,8:11],4,2)) ***** test - b = [3 1]; - a = [1 .5]; - f = isminphase (b, a); - assert (f, true) + [y, z] = buffer(1:12,4); + assert (y, reshape(1:12,4,3)); + assert (z, zeros (1,0)); ***** test - [b, a] = butter (1, .5); - f = isminphase (b, a); - assert (f, false) + [y, z] = buffer(1:11,4); + assert (y, reshape(1:8,4,2)); + assert (z, [9, 10, 11]); ***** test - [b, a] = butter (8, .5); - f = isminphase (b, a); - assert (f, false) + [y, z] = buffer([1:12]',4); + assert (y, reshape(1:12,4,3)); + assert (z, zeros (0,1)); ***** test - b = 1.25^2 * conv (conv (conv ([1 -0.9*e^(-j*0.6*pi)], [1 -0.9*e^(j*0.6*pi)]), [1 -0.8*e^(-j*0.8*pi)]), [1 -0.8*e^(j*0.8*pi)]); - a = 1; - f = isminphase (b, a); - assert (f, true) -12 tests, 12 passed, 0 known failure, 0 skipped -[inst/butter.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/butter.m -***** shared sf, sf2, off_db - off_db = 0.5; - ## Sampling frequency must be that high to make the low pass filters pass. - sf = 6000; sf2 = sf/2; - data=[sinetone(5,sf,10,1),sinetone(10,sf,10,1),sinetone(50,sf,10,1),sinetone(200,sf,10,1),sinetone(400,sf,10,1)]; + [y, z] = buffer([1:11]',4); + assert (y, reshape(1:8,4,2)); + assert (z, [9; 10; 11]); ***** test - ## Test low pass order 1 with 3dB @ 50Hz - data=[sinetone(5,sf,10,1),sinetone(10,sf,10,1),sinetone(50,sf,10,1),sinetone(200,sf,10,1),sinetone(400,sf,10,1)]; - [b, a] = butter ( 1, 50 / sf2 ); - filtered = filter ( b, a, data ); - damp_db = 20 * log10 ( max ( filtered ( end - sf : end, : ) ) ); - assert ( [ damp_db( 4 ) - damp_db( 5 ), damp_db( 1 : 3 ) ], [ 6 0 0 -3 ], off_db ) + [y,z,opt] = buffer(1:15,4,-2,1); + assert (y, reshape([2:5,8:11],4,2)); + assert (z, [14, 15]); + assert (opt, 0); ***** test - ## Test low pass order 4 with 3dB @ 50Hz - data=[sinetone(5,sf,10,1),sinetone(10,sf,10,1),sinetone(50,sf,10,1),sinetone(200,sf,10,1),sinetone(400,sf,10,1)]; - [b, a] = butter ( 4, 50 / sf2 ); - filtered = filter ( b, a, data ); - damp_db = 20 * log10 ( max ( filtered ( end - sf : end, : ) ) ); - assert ( [ damp_db( 4 ) - damp_db( 5 ), damp_db( 1 : 3 ) ], [ 24 0 0 -3 ], off_db ) + [y,z,opt] = buffer(1:11,4,-2,1); + assert (y, reshape([2:5,8:11],4,2)); + assert (z, zeros (1,0)); + assert (opt, 2); ***** test - ## Test high pass order 1 with 3dB @ 50Hz - data=[sinetone(5,sf,10,1),sinetone(10,sf,10,1),sinetone(50,sf,10,1),sinetone(200,sf,10,1),sinetone(400,sf,10,1)]; - [b, a] = butter ( 1, 50 / sf2, "high" ); - filtered = filter ( b, a, data ); - damp_db = 20 * log10 ( max ( filtered ( end - sf : end, : ) ) ); - assert ( [ damp_db( 2 ) - damp_db( 1 ), damp_db( 3 : end ) ], [ 6 -3 0 0 ], off_db ) + [y,z,opt] = buffer([1:15]',4,-2,1); + assert (y, reshape([2:5,8:11],4,2)); + assert (z, [14; 15]); + assert (opt, 0); ***** test - ## Test high pass order 4 with 3dB @ 50Hz - data=[sinetone(5,sf,10,1),sinetone(10,sf,10,1),sinetone(50,sf,10,1),sinetone(200,sf,10,1),sinetone(400,sf,10,1)]; - [b, a] = butter ( 4, 50 / sf2, "high" ); - filtered = filter ( b, a, data ); - damp_db = 20 * log10 ( max ( filtered ( end - sf : end, : ) ) ); - assert ( [ damp_db( 2 ) - damp_db( 1 ), damp_db( 3 : end ) ], [ 24 -3 0 0 ], off_db ) -***** error [a, b] = butter () -***** error [a, b] = butter (1) -***** error [a, b] = butter (1, 2, 3, 4, 5) -***** error [a, b] = butter (.5, .2) -***** error [a, b] = butter (3, .2, "invalid") -***** error [a, b] = butter (9, .6, "stop") -***** error [a, b] = butter (9, .6, "bandpass") -***** error [a, b] = butter (9, .6, "s", "high") + [y,z,opt] = buffer([1:11]',4,-2,1); + assert (y, reshape([2:5,8:11],4,2)); + assert (z, zeros (0, 1)); + assert (opt, 2); ***** test - butter (9, .6); - assert (isrow (ans)); + [y,z,opt] = buffer([1:11],5,2,[-1,0]); + assert (y, reshape ([-1:3,2:6,5:9],[5,3])); + assert (z, [10, 11]); + assert (opt, [8; 9]); ***** test - A = butter (9, .6); - assert (isrow (A)); + [y,z,opt] = buffer([1:11]',5,2,[-1,0]); + assert (y, reshape ([-1:3,2:6,5:9],[5,3])); + assert (z, [10; 11]); + assert (opt, [8; 9]); ***** test - [A, B] = butter (9, .6); - assert (isrow (A)); - assert (isrow (B)); + [y, z, opt] = buffer (1:10, 6, 4); + assert (y, [0 0 1:2:5; 0 0 2:2:6; 0 1:2:7; 0 2:2:8; 1:2:9; 2:2:10]) + assert (z, zeros (1, 0)) + assert (opt, [7; 8; 9; 10]) +29 tests, 29 passed, 0 known failure, 0 skipped +[inst/fir1.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/fir1.m +***** demo + freqz(fir1(40,0.3)); +***** demo + freqz(fir1(15,[0.2, 0.5], 'stop')); # note the zero-crossing at 0.1 +***** demo + freqz(fir1(15,[0.2, 0.5], 'stop', 'noscale')); +***** assert(fir1(2, .5, 'low', @hanning, 'scale'), [0 1 0]); +***** assert(fir1(2, .5, 'low', "hanning", 'scale'), [0 1 0]); +***** assert(fir1(2, .5, 'low', hanning(3), 'scale'), [0 1 0]); +***** assert(fir1(10,.5,'noscale'), fir1(10,.5,'low','hamming','noscale')); +***** assert(fir1(10,.5,'high'), fir1(10,.5,'high','hamming','scale')); +***** assert(fir1(10,.5,'boxcar'), fir1(10,.5,'low','boxcar','scale')); +***** assert(fir1(10,.5,'hanning','scale'), fir1(10,.5,'scale','hanning','low')); +***** assert(fir1(10,.5,'haNNing','NOscale'), fir1(10,.5,'noscale','Hanning','LOW')); +***** assert(fir1(10,.5,'boxcar',[]), fir1(10,.5,'boxcar')); ***** test - [z, p, g] = butter (9, .6); - assert (iscolumn (z)); - assert (iscolumn (p)); - assert (isscalar (g)); + b = fir1 (30, 0.3); + h = abs (freqz (b, 1, [0, 0.3, 1], 2)); + assert (h(1), 1, 1e-3) + assert (all (h(2:3) <= [1/sqrt(2), 3e-3])) ***** test - [a, b, c, d] = butter (9, .6); - assert (ismatrix (a)); - assert (iscolumn (b)); - assert (isrow (c)); - assert (isscalar (d)); -***** demo - sf = 800; sf2 = sf/2; - data=[[1;zeros(sf-1,1)],sinetone(25,sf,1,1),sinetone(50,sf,1,1),sinetone(100,sf,1,1)]; - [b,a]=butter ( 1, 50 / sf2 ); - filtered = filter(b,a,data); - - clf - subplot ( columns ( filtered ), 1, 1) - plot(filtered(:,1),";Impulse response;") - subplot ( columns ( filtered ), 1, 2 ) - plot(filtered(:,2),";25Hz response;") - subplot ( columns ( filtered ), 1, 3 ) - plot(filtered(:,3),";50Hz response;") - subplot ( columns ( filtered ), 1, 4 ) - plot(filtered(:,4),";100Hz response;") -17 tests, 17 passed, 0 known failure, 0 skipped -[inst/czt.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/czt.m -***** shared x - x = [1,2,4,1,2,3,5,2,3,5,6,7,8,4,3,6,3,2,5,1]; -***** assert(fft(x),czt(x),10000*eps); -***** assert(fft(x'),czt(x'),10000*eps); -***** assert(fft([x',x']),czt([x',x']),10000*eps); -3 tests, 3 passed, 0 known failure, 0 skipped -[inst/rms.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/rms.m -***** assert (rms (0), 0) -***** assert (rms (1), 1) -***** assert (rms ([1 2 -1]), sqrt (2)) -***** assert (rms ([1 2 -1]'), sqrt (2)) -***** assert (rms ([1 2], 3), [1 2]) -***** error rms () -***** error rms (1, 2, 3) -***** error rms (1, 1.5) -***** error rms (1, -1) -9 tests, 9 passed, 0 known failure, 0 skipped -[inst/barthannwin.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/barthannwin.m -***** assert (barthannwin (1), 1) -***** assert (barthannwin (2), zeros (2, 1)) -***** error barthannwin () -***** error barthannwin (0.5) -***** error barthannwin (-1) -***** error barthannwin (ones (1, 4)) -***** error barthannwin (1, 2) -7 tests, 7 passed, 0 known failure, 0 skipped -[inst/cheb1ord.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cheb1ord.m + b = fir1 (30, 0.7, "high"); + h = abs (freqz (b, 1, [0, 0.7, 1], 2)); + assert (h(3), 1, 1e-3) + assert (all (h(1:2) <= [3e-3, 1/sqrt(2)])) +***** test + b = fir1 (30, [0.3, 0.7]); + h = abs (freqz (b, 1, [0, 0.3, 0.5, 0.7, 1], 2)); + assert (h(3), 1, 1e-3) + assert (all (h([1:2, 4:5]) <= [3e-3, 1/sqrt(2), 1/sqrt(2), 3e-3])) +***** test + b = fir1 (50, [0.3, 0.7], "stop"); + h = abs (freqz (b, 1, [0, 0.3, 0.5, 0.7, 1], 2)); + assert (h(1), 1, 1e-3) + assert (h(5), 1, 1e-3) + assert (all (h(2:4) <= [1/sqrt(2), 3e-3, 1/sqrt(2)])) +13 tests, 13 passed, 0 known failure, 0 skipped +[inst/cheb2ord.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cheb2ord.m ***** demo fs = 44100; fpass = 4000; @@ -4528,14 +4982,14 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby1 (n, Rpass, Wn_p); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby2 (n, Rstop, Wn_p); SYS = tf (b, a, 1 / fs); f = (0:fs/2)'; W = f * (2 * pi / fs); [H, P] = bode (SYS, 2 * pi * f); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev low-pass Typ I : matching pass band"); + title ("Digital Chebyshev low-pass Typ II : matching pass band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4555,14 +5009,14 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby1 (n, Rpass, Wn_s); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby2 (n, Rstop, Wn_s); SYS = tf (b, a, 1 / fs); f = (0:fs/2)'; W = f * (2 * pi / fs); [H, P] = bode (SYS, 2 * pi * f); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev low-pass Typ I : matching stop band"); + title ("Digital Chebyshev low-pass Typ II : matching stop band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4582,13 +5036,13 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby1 (n, Rpass, Wn_p, "high"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby2 (n, Rstop, Wn_p, "high"); f = (0:fs/2)'; W = f * (2 * pi / fs); H = freqz (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev high-pass Typ I : matching pass band"); + title ("Digital Chebyshev high-pass Typ II : matching pass band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4608,13 +5062,13 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby1 (n, Rpass, Wn_s, "high"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby2 (n, Rstop, Wn_s, "high"); f = (0:fs/2)'; W = f * (2 * pi / fs); H = freqz (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev high-pass Typ I : matching stop band"); + title ("Digital Chebyshev high-pass Typ II : matching stop band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4634,13 +5088,13 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby1 (n, Rpass, Wn_p); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby2 (n, Rstop, Wn_p); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev band-pass Typ I : matching pass band, limit on upper freq"); + title ("Digital Chebyshev band-pass Typ II : matching pass band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4663,13 +5117,13 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby1 (n, Rpass, Wn_s); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby2 (n, Rstop, Wn_s); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev band-pass Typ I : matching stop band, limit on upper freq"); + title ("Digital Chebyshev band-pass Typ II : matching stop band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4692,13 +5146,13 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby1 (n, Rpass, Wn_p); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby2 (n, Rstop, Wn_p); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev band-pass Typ I : matching pass band, limit on lower freq"); + title ("Digital Chebyshev band-pass Typ II : matching pass band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4721,13 +5175,13 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby1 (n, Rpass, Wn_s); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby2 (n, Rstop, Wn_s); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev band-pass Typ I : matching stop band, limit on lower freq"); + title ("Digital Chebyshev band-pass Typ II : matching stop band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4750,14 +5204,14 @@ Rstop = 40; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby1 (n, Rpass, Wn_p, "stop"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby2 (n, Rstop, Wn_p, "stop"); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); Ampl = abs (H); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev notch Typ I : matching pass band, limit on upper freq"); + title ("Digital Chebyshev notch Typ II : matching pass band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4781,14 +5235,14 @@ Rstop = 40; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby1 (n, Rpass, Wn_s, "stop"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby2 (n, Rstop, Wn_s, "stop"); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); Ampl = abs (H); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev notch Typ I : matching stop band, limit on upper freq"); + title ("Digital Chebyshev notch Typ II : matching stop band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4812,14 +5266,14 @@ Rstop = 40; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby1 (n, Rpass, Wn_p, "stop"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby2 (n, Rstop, Wn_p, "stop"); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); Ampl = abs (H); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev notch Typ I : matching pass band, limit on lower freq"); + title ("Digital Chebyshev notch Typ II : matching pass band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4843,14 +5297,14 @@ Rstop = 40; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby1 (n, Rpass, Wn_s, "stop"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby2 (n, Rstop, Wn_s, "stop"); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); Ampl = abs (H); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev notch Typ I : matching stop band, limit on lower freq"); + title ("Digital Chebyshev notch Typ II : matching stop band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4873,13 +5327,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby1 (n, Rpass, Wn_p, "s"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby2 (n, Rstop, Wn_p, "s"); f = 1000:10:100000; W = 2 * pi * f; H = freqs (b, a, W); semilogx (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev low-pass Typ I : matching pass band"); + title ("Analog Chebyshev low-pass Typ II : matching pass band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4898,13 +5352,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby1 (n, Rpass, Wn_s, "s"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby2 (n, Rstop, Wn_s, "s"); f = 1000:10:100000; W = 2 * pi * f; H = freqs (b, a, W); semilogx (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev low-pass Typ I : matching stop band"); + title ("Analog Chebyshev low-pass Typ II : matching stop band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4923,13 +5377,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby1 (n, Rpass, Wn_p, "high", "s"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby2 (n, Rstop, Wn_p, "high", "s"); f = 1000:10:100000; W = 2 * pi * f; H = freqs (b, a, W); semilogx (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev high-pass Typ I : matching pass band"); + title ("Analog Chebyshev high-pass Typ II : matching pass band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4948,13 +5402,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby1 (n, Rpass, Wn_s, "high", "s"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby2 (n, Rstop, Wn_s, "high", "s"); f = 1000:10:100000; W = 2 * pi * f; H = freqs (b, a, W); semilogx (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev high-pass Typ I : matching stop band"); + title ("Analog Chebyshev high-pass Typ II : matching stop band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -4973,13 +5427,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby1 (n, Rpass, Wn_p, "s"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby2 (n, Rstop, Wn_p, "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev band-pass Typ I : matching pass band, limit on upper freq"); + title ("Analog Chebyshev band-pass Typ II : matching pass band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -5001,13 +5455,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby1 (n, Rpass, Wn_s, "s"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby2 (n, Rstop, Wn_s, "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev band-pass Typ I : matching stop band, limit on upper freq"); + title ("Analog Chebyshev band-pass Typ II : matching stop band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -5029,13 +5483,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby1 (n, Rpass, Wn_p, "s"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby2 (n, Rstop, Wn_p, "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev band-pass Typ I : matching pass band, limit on lower freq"); + title ("Analog Chebyshev band-pass Typ II : matching pass band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -5057,13 +5511,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby1 (n, Rpass, Wn_s, "s"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby2 (n, Rstop, Wn_s, "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev band-pass Typ I : matching stop band, limit on lower freq"); + title ("Analog Chebyshev band-pass Typ II : matching stop band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -5085,13 +5539,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby1 (n, Rpass, Wn_p, "stop", "s"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby2 (n, Rstop, Wn_p, "stop", "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev notch Typ I : matching pass band, limit on upper freq"); + title ("Analog Chebyshev notch Typ II : matching pass band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -5114,13 +5568,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby1 (n, Rpass, Wn_s, "stop", "s"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby2 (n, Rstop, Wn_s, "stop", "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev notch Typ I : matching stop band, limit on upper freq"); + title ("Analog Chebyshev notch Typ II : matching stop band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -5143,13 +5597,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby1 (n, Rpass, Wn_p, "stop", "s"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby2 (n, Rstop, Wn_p, "stop", "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev notch Typ I : matching pass band, limit on lower freq"); + title ("Analog Chebyshev notch Typ II : matching pass band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -5172,13 +5626,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby1 (n, Rpass, Wn_s, "stop", "s"); + [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby2 (n, Rstop, Wn_s, "stop", "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev notch Typ I : matching stop band, limit on lower freq"); + title ("Analog Chebyshev notch Typ II : matching stop band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -5196,1229 +5650,2391 @@ ylim ([-80, 0]); ***** test # Analog band-pass - [n, Wn_p, Wn_s] = cheb1ord (2 * pi * [9875, 10126.5823], ... + [n, Wn_p, Wn_s] = cheb2ord (2 * pi * [9875, 10126.5823], ... 2 * pi * [9000, 10437], 1, 26, "s"); assert (n, 3); - assert (round (Wn_p), [62046, 63627]); - assert (round (Wn_s), [61652, 64035]); + assert (round (Wn_p), [61074, 64640]); + assert (round (Wn_s), [60201, 65578]); ***** test # Analog band-pass - [n, Wn_p, Wn_s] = cheb1ord (2 * pi * [9875, 10126.5823], ... + [n, Wn_p, Wn_s] = cheb2ord (2 * pi * [9875, 10126.5823], ... 2 * pi * [9581 12000], 1, 26, "s"); assert (n, 3); - assert (round (Wn_p), [62046, 63627]); - assert (round (Wn_s), [61651, 64036]); + assert (round (Wn_p), [61074, 64640]); + assert (round (Wn_s), [60199, 65580]); ***** test # Analog high-pass - [n, Wn_p, Wn_s] = cheb1ord (2 * pi * 13584, 2 * pi * 4000, 1, 26, "s"); + [n, Wn_p, Wn_s] = cheb2ord (2 * pi * 13584, 2 * pi * 4000, 1, 26, "s"); assert (n, 3); - assert (round (Wn_p), 85351); - assert (round (Wn_s), 56700); + assert (round (Wn_p), 37832); + assert (round (Wn_s), 25133); ***** test # Analog low-pass - [n, Wn_p, Wn_s] = cheb1ord (2 * pi * 4000, 2 * pi * 13584, 1, 26, "s"); + [n, Wn_p, Wn_s] = cheb2ord (2 * pi * 4000, 2 * pi * 13584, 1, 26, "s"); assert (n, 3); - assert (round (Wn_p), 25133); - assert (round (Wn_s), 37832); + assert (round (Wn_p), 56700); + assert (round (Wn_s), 85351); ***** test # Analog notch (narrow band-stop) - [n, Wn_p, Wn_s] = cheb1ord (2 * pi * [9000, 10437], ... + [n, Wn_p, Wn_s] = cheb2ord (2 * pi * [9000, 10437], ... 2 * pi * [9875, 10126.5823], 1, 26, "s"); assert (n, 3); - assert (round (Wn_p), [60201, 65578]); - assert (round (Wn_s), [61074, 64640]); + assert (round (Wn_p), [61652, 64035]); + assert (round (Wn_s), [62046, 63627]); ***** test # Analog notch (narrow band-stop) - [n, Wn_p, Wn_s] = cheb1ord (2 * pi * [9581, 12000], ... + [n, Wn_p, Wn_s] = cheb2ord (2 * pi * [9581, 12000], ... 2 * pi * [9875, 10126.5823], 1, 26, "s"); assert (n, 3); - assert (round (Wn_p), [60199, 65580]); - assert (round (Wn_s), [61074, 64640]); + assert (round (Wn_p), [61651, 64036]); + assert (round (Wn_s), [62046, 63627]); ***** test # Digital band-pass fs = 44100; - [n, Wn_p, Wn_s] = cheb1ord (2 / fs * [9500, 9750], ... + [n, Wn_p, Wn_s] = cheb2ord (2 / fs * [9500, 9750], ... 2 / fs * [8500, 10052], 1, 26); Wn_p = Wn_p * fs / 2; Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn_p), [9500, 9750]); - assert (round (Wn_s), [9437, 9814]); + assert (round (Wn_p), [9344, 9908]); + assert (round (Wn_s), [9203, 10052]); ***** test # Digital band-pass fs = 44100; - [n, Wn_p, Wn_s] = cheb1ord (2 / fs * [9500, 9750], ... + [n, Wn_p, Wn_s] = cheb2ord (2 / fs * [9500, 9750], ... 2 / fs * [9182, 12000], 1, 26); Wn_p = Wn_p * fs / 2; Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn_p), [9500, 9750]); - assert (round (Wn_s), [9428, 9823]); + assert (round (Wn_p), [9344, 9908]); + assert (round (Wn_s), [9182, 10073]); ***** test # Digital high-pass fs = 44100; - [n, Wn_p, Wn_s] = cheb1ord (2 / fs * 10988, 2 / fs * 4000, 1, 26); + [n, Wn_p, Wn_s] = cheb2ord (2 / fs * 10988, 2 / fs * 4000, 1, 26); Wn_p = Wn_p * fs / 2; Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn_p), 10988); - assert (round (Wn_s), 8197); + assert (round (Wn_p), 5829); + assert (round (Wn_s), 4000); ***** test # Digital low-pass fs = 44100; - [n, Wn_p, Wn_s] = cheb1ord (2 / fs * 4000, 2 / fs * 10988, 1, 26); + [n, Wn_p, Wn_s] = cheb2ord (2 / fs * 4000, 2 / fs * 10988, 1, 26); Wn_p = Wn_p * fs / 2; Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn_p), 4000); - assert (round (Wn_s), 5829); + assert (round (Wn_p), 8197); + assert (round (Wn_s), 10988); ***** test # Digital notch (narrow band-stop) fs = 44100; - [n, Wn_p, Wn_s] = cheb1ord (2 / fs * [8500, 10834], ... + [n, Wn_p, Wn_s] = cheb2ord (2 / fs * [8500, 10834], ... 2 / fs * [9875, 10126.5823], 0.5, 40); Wn_p = Wn_p * fs / 2; Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn_p), [9182, 10834]); - assert (round (Wn_s), [9475, 10532]); + assert (round (Wn_p), [9804, 10198]); + assert (round (Wn_s), [9875, 10127]); ***** test # Digital notch (narrow band-stop) fs = 44100; - [n, Wn_p, Wn_s] = cheb1ord (2 / fs * [9182 12000], ... + [n, Wn_p, Wn_s] = cheb2ord (2 / fs * [9182 12000], ... 2 / fs * [9875, 10126.5823], 0.5, 40); Wn_p = Wn_p * fs / 2; Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn_p), [9182, 10834]); - assert (round (Wn_s), [9475, 10532]); -***** error cheb1ord () -***** error cheb1ord (.1) -***** error cheb1ord (.1, .2) -***** error cheb1ord (.1, .2, 3) -***** error cheb1ord ([.1 .1], [.2 .2], 3, 4) -***** error cheb1ord ([.1 .2], [.5 .6], 3, 4) -***** error cheb1ord ([.1 .5], [.2 .6], 3, 4) + assert (round (Wn_p), [9804, 10198]); + assert (round (Wn_s), [9875, 10127]); +***** error cheb2ord () +***** error cheb2ord (.1) +***** error cheb2ord (.1, .2) +***** error cheb2ord (.1, .2, 3) +***** error cheb2ord ([.1 .1], [.2 .2], 3, 4) +***** error cheb2ord ([.1 .2], [.5 .6], 3, 4) +***** error cheb2ord ([.1 .5], [.2 .6], 3, 4) 19 tests, 19 passed, 0 known failure, 0 skipped -[inst/decimate.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/decimate.m -***** demo - t=0:0.01:2; x=chirp(t,2,.5,10,'quadratic')+sin(2*pi*t*0.4); - y = decimate(x,4); # factor of 4 decimation - stem(t(1:121)*1000,x(1:121),"-g;Original;"); hold on; # plot original - stem(t(1:4:121)*1000,y(1:31),"-r;Decimated;"); hold off; # decimated - %------------------------------------------------------------------ - % The signal to decimate starts away from zero, is slowly varying - % at the start and quickly varying at the end, decimate and plot. - % Since it starts away from zero, you will see the boundary - % effects of the antialiasing filter clearly. You will also see - % how it follows the curve nicely in the slowly varying early - % part of the signal, but averages the curve in the quickly - % varying late part of the signal. -***** error decimate () -***** error decimate (1) -***** error decimate (1, 2, 3, 4, 5) -***** error decimate (1, -1) -4 tests, 4 passed, 0 known failure, 0 skipped -[inst/data2fun.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/data2fun.m -***** shared t, y - t = linspace (0, 1, 10); - y = t.^2 - 2*t + 1; +[inst/xcorr.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/xcorr.m +***** shared x, y + x = 0.5.^(0:15); + y = circshift(x,5); +***** error xcorr () +***** error xcorr (1) +***** error xcorr (x, 1, x) +***** error xcorr (x, 'none', x) +***** error xcorr (x, x, 'invalid') +***** error xcorr (x, 'invalid') ***** test - fhandle = data2fun (t, y); - assert (y, fhandle (t)); + [c,lags] = xcorr(x); + # largest spike at 0 lag, where X matches itself - ie the center + [m, im] = max(c); + assert(m, 4/3, 1e-6) + assert(im, (numel(lags)+1)/2); + + [c1,lags1] = xcorr(x, x); + [m, im] = max(c1); + assert(m, 4/3, 1e-6) + assert(im, (numel(lags1)+1)/2); + assert(c1, c, 2*eps); + assert(lags1, lags); ***** test - unwind_protect - # Change to temporary folder in case tester cannot write current folder - olddir = pwd(); - cd(tempdir()); + [c,lags] = xcorr(x,y); + # largest spike at 0 lag, where X matches Y + [m, im] = max(c); + assert(m, 4/3, 1e-6) + assert(lags(im), -5); +***** test + [c0,lags0] = xcorr(x,y); + [c1,lags1] = xcorr(x,y, 'none'); + assert(c0, c1); + assert(lags0, lags1); +***** test + [c0,lags0] = xcorr(x,y); + [c1,lags1] = xcorr(x,y, 'normalized'); + assert(lags0, lags1); + [m, im] = max(c1); + # at 0 lag, should be 1 + assert(m, 1, 1e-6); + [c2,lags2] = xcorr(x,y, 'coeff'); + assert(c1, c2); + assert(lags1, lags2); +***** test + [c0,lags0] = xcorr(x,y); + [c1,lags1] = xcorr(x,y, 'biased'); + assert(lags0, lags1); + [m, im] = max(c1); + assert(m, 1/12, 1e-6); - [fhandle fname] = data2fun (t, y, "file", "testdata2fun"); - yt = testdata2fun (t); - assert (y, yt); - assert (y, fhandle (t)); - unwind_protect_cleanup - unlink (fname); - unlink ([fname(1:end-2) ".mat"]); - cd(olddir) - end_unwind_protect + [c1,lags1] = xcorr(x, 'biased'); + assert(lags0, lags1); + [m, im] = max(c1); + assert(m, 1/12, 1e-6); ***** test - unwind_protect - # Change to temporary folder in case tester cannot write current folder - olddir = pwd(); - cd(tempdir()); + [c0,lags0] = xcorr(x,y); + [c1,lags1] = xcorr(x,y, 'unbiased'); + assert(lags0, lags1); + [m, im] = max(c1); + assert(m, 1/8.25, 1e-6); +***** test + [c,lags] = xcorr(x,y, 10); + [m, im] = max(c); + assert(lags(im), -5); + assert(lags(1), -10); + assert(lags(end), 10); - [fhandle fname] = data2fun (t, y, "file", ""); - # generate commmand to execute using random file name - cmd = sprintf ("yt = %s(t);", nthargout (2, @fileparts, fname)); - eval (cmd); - assert (y, yt); - assert (y, fhandle (t)); - unwind_protect_cleanup - unlink (fname); - unlink ([fname(1:end-2) ".mat"]); - cd(olddir) - end_unwind_protect + [c,lags] = xcorr(x,10); + [m, im] = max(c); + assert(lags(1), -10); + assert(lags(end), 10); ***** test - unwind_protect - # Change to temporary folder in case tester cannot write current folder - olddir = pwd(); - cd(tempdir()); - [fhandle fname] = data2fun (t, y, "file", "testdata2fun", "interp", "linear"); - yt = testdata2fun (t); - assert (y, yt); - assert (y, fhandle (t)); - unwind_protect_cleanup - unlink (fname); - unlink ([fname(1:end-2) ".mat"]); - cd(olddir) - end_unwind_protect -***** error data2fun () -***** error data2fun (1) -***** error data2fun (1, 2, "file") -7 tests, 7 passed, 0 known failure, 0 skipped -[inst/sos2zp.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/sos2zp.m + [c0,lags0] = xcorr(x,y, 'normalized', 10); + [c1,lags1] = xcorr(x,y, 10, 'normalized'); + assert(c0, c1); + assert(lags0, lags1); +14 tests, 14 passed, 0 known failure, 0 skipped +[inst/fir2.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/fir2.m +***** xtest + f = [0 0.6 0.6 1]; m = [1 1 0 0]; + b9 = fir2 (30, f, m, 9); + b16 = fir2 (30, f, m, 16); + b17 = fir2 (30, f, m, 17); + b32 = fir2 (30, f, m, 32); + assert ( isequal (b9, b16)) + assert ( isequal (b17, b32)) + assert (~isequal (b16, b17)) ***** test - b1t=[1 2 3]; a1t=[1 .2 .3]; - b2t=[4 5 6]; a2t=[1 .4 .5]; - sos=[b1t a1t; b2t a2t]; - z = [-1-1.41421356237310i;-1+1.41421356237310i;... - -0.625-1.05326872164704i;-0.625+1.05326872164704i]; - p = [-0.2-0.678232998312527i;-0.2+0.678232998312527i;... - -0.1-0.538516480713450i;-0.1+0.538516480713450i]; - k = 4; - [z2,p2,k2] = sos2zp(sos,1); - assert({cplxpair(z2),cplxpair(p2),k2},{z,p,k},100*eps); + f = [0, 0.7, 0.7, 1]; m = [0, 0, 1, 1]; + b = fir2 (50, f, m); + h = abs (freqz (b, 1, [0, 0.7, 1], 2)); + assert (h(1) <= 3e-3) + assert (h(2) <= 1/sqrt (2)) + assert (h(3), 1, 2e-3) ***** test - sos = [1, 1, 0, 1, 1, 0.5]; - [Z, P] = sos2zp (sos); - assert (Z, roots (sos(1,1:3)), 10*eps); - assert (P, roots (sos(1,4:6)), 10*eps); + f = [0, 0.25, 0.25, 0.75, 0.75, 1]; m = [0, 0, 1, 1, 0, 0]; + b = fir2 (50, f, m); + h = abs (freqz (b, 1, [0, 0.25, 0.5, 0.75, 1], 2)); + assert (h(1) <= 3e-3) + assert (h(2) <= 1/sqrt (2)) + assert (h(3), 1, 2e-3) + assert (h(4) <= 1/sqrt (2)) + assert (h(5) <= 3e-3) ***** test - sos = [0, 1, 1, 1, 0.5, 0]; - [Z, P] = sos2zp (sos); - assert (Z, roots (sos(1,1:3)), 10*eps); - assert (P, roots (sos(1,4:6)), 10*eps); + f = [0, 0.45, 0.45, 0.55, 0.55, 1]; m = [1, 1, 0, 0, 1, 1]; + b = fir2 (50, f, m); + h = abs (freqz (b, 1, [0, 0.45, 0.5, 0.55, 1], 2)); + assert (h(1), 1, 2e-3) + assert (h(2) <= 1/sqrt (2)) + assert (h(3) <= 1e-1) + assert (h(4) <= 1/sqrt (2)) + assert (h(5), 1, 2e-3) +***** test #bug 59066 + f = [0, 0.45, 0.45, 0.55, 0.55, 1]; m = [1, 1, 0, 0, 1, 1]; + b = fir2 (int32(50), f, m); + assert(numel(b), 51) + + fail ("fir2 (50.1, f, m)", "fir2: n must be a non negative integer") + fail ("fir2 (-1, f, m)", "fir2: n must be a non negative integer") +***** demo + f=[0, 0.3, 0.3, 0.6, 0.6, 1]; m=[0, 0, 1, 1/2, 0, 0]; + [h, w] = freqz(fir2(100,f,m)); + subplot(121); + plot(f,m,';target response;',w/pi,abs(h),';filter response;'); + subplot(122); + plot(f,20*log10(m+1e-5),';target response (dB);',... + w/pi,20*log10(abs(h)),';filter response (dB);'); +***** demo + f=[0, 0.3, 0.3, 0.6, 0.6, 1]; m=[0, 0, 1, 1/2, 0, 0]; + plot(f,20*log10(m+1e-5),';target response;'); + hold on; + [h, w] = freqz(fir2(50,f,m,512,0)); + plot(w/pi,20*log10(abs(h)),';filter response (ramp=0);'); + [h, w] = freqz(fir2(50,f,m,512,25.6)); + plot(w/pi,20*log10(abs(h)),';filter response (ramp=pi/20 rad);'); + [h, w] = freqz(fir2(50,f,m,512,51.2)); + plot(w/pi,20*log10(abs(h)),';filter response (ramp=pi/10 rad);'); + hold off; +***** demo + % Classical Jakes spectrum + % X represents the normalized frequency from 0 + % to the maximum Doppler frequency + asymptote = 2/3; + X = linspace(0,asymptote-0.0001,200); + Y = (1 - (X./asymptote).^2).^(-1/4); + + % The target frequency response is 0 after the asymptote + X = [X, asymptote, 1]; + Y = [Y, 0, 0]; + + plot(X,Y,'b;Target spectrum;'); + hold on; + [H,F]=freqz(fir2(20, X, Y)); + plot(F/pi,abs(H),'c;Synthesized spectrum (n=20);'); + [H,F]=freqz(fir2(50, X, Y)); + plot(F/pi,abs(H),'r;Synthesized spectrum (n=50);'); + [H,F]=freqz(fir2(200, X, Y)); + plot(F/pi,abs(H),'g;Synthesized spectrum (n=200);'); + hold off; + title('Theoretical/Synthesized CLASS spectrum'); + xlabel('Normalized frequency (Fs=2)'); + ylabel('Magnitude'); +5 tests, 5 passed, 0 known failure, 0 skipped +[inst/impz.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/impz.m +***** assert (size (impz (1, [1 -1 0.9], 100)), [100 1]) +***** xtest + [h, t] = impz (1, [1 -1 0.9], 0:101); + assert (size (h), [101 1]) + assert (t, 0:101) +!!!!! known failure +impz: N must be empty or a scalar +2 tests, 1 passed, 1 known failure, 0 skipped +[inst/rectwin.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/rectwin.m +***** assert (rectwin (1), 1) +***** assert (rectwin (2), ones (2, 1)) +***** assert (rectwin (100), ones (100, 1)) +***** error rectwin () +***** error rectwin (0.5) +***** error rectwin (-1) +***** error rectwin (ones (1, 4)) +***** error rectwin (1, 2) +8 tests, 8 passed, 0 known failure, 0 skipped +[inst/peak2peak.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/peak2peak.m ***** test - sos = [1, 1, 0, 1, 0.5, 0]; - [Z, P] = sos2zp (sos); - assert (Z, roots (sos(1,1:3)), 10*eps); - assert (P, roots (sos(1,4:6)), 10*eps); + X = [23 42 85; 62 46 65; 18 40 28]; + Y = peak2peak (X); + assert (Y, [44 6 57]); + Y = peak2peak (X, 1); + assert (Y, [44 6 57]); + Y = peak2peak (X, 2); + assert (Y, [62; 19; 22]); ***** test - sos = [0, 1, 1, 1, 1, 0.5]; - [Z, P] = sos2zp (sos); - assert (Z, roots (sos(1,1:3)), 10*eps); - assert (P, roots (sos(1,4:6)), 10*eps); + X = [71 62 33]; + X(:, :, 2) = [88 36 21]; + X(:, :, 3) = [83 46 85]; + Y = peak2peak (X); + T = [38]; + T(:, :, 2) = [67]; + T(:, :, 3) = [39]; + assert (Y, T); ***** test - sos = [1, 1, 0, 0, 1, 0.5]; - [Z, P] = sos2zp (sos); - assert (Z, roots (sos(1,1:3)), 10*eps); - assert (P, roots (sos(1,4:6)), 10*eps); + X = [71 72 22; 16 22 50; 29 44 14]; + X(:, :, 2) = [10 15 62; 1 94 30; 72 43 53]; + X(:, :, 3) = [57 98 32; 84 95 51; 25 24 0]; + Y = peak2peak (X); + T = [55 50 36]; + T(:, :, 2) = [71 79 32]; + T(:, :, 3) = [59 74 51]; + assert (Y, T); + Y = peak2peak (X, 2); + T = [50; 34; 30]; + T(:, :, 2) = [52; 93; 29]; + T(:, :, 3) = [66; 44; 25]; + assert (Y, T); + Y = peak2peak (X, 3); + T = [61 83 40; 83 73 21; 47 20 53]; + assert (Y, T); ***** test - sos = [0, 1, 1, 0, 1, 0.5]; - [Z, P] = sos2zp (sos); - assert (Z, roots (sos(1,1:3)), 10*eps); - assert (P, roots (sos(1,4:6)), 10*eps); -7 tests, 7 passed, 0 known failure, 0 skipped -[inst/upsample.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/upsample.m -***** assert(upsample([1,3,5],2),[1,0,3,0,5,0]); -***** assert(upsample([1;3;5],2),[1;0;3;0;5;0]); -***** assert(upsample([1,2;5,6;9,10],2),[1,2;0,0;5,6;0,0;9,10;0,0]); -***** assert(upsample([2,4],2,1),[0,2,0,4]); -***** assert(upsample([3,4;7,8],2,1),[0,0;3,4;0,0;7,8]); -5 tests, 5 passed, 0 known failure, 0 skipped -[inst/boxcar.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/boxcar.m -***** assert (boxcar (1), 1) -***** assert (boxcar (2), ones (2, 1)) -***** assert (boxcar (100), ones (100, 1)) -***** error boxcar () -***** error boxcar (0.5) -***** error boxcar (-1) -***** error boxcar (ones (1, 4)) -***** error boxcar (1, 2) + X = [60 61; 77 77]; + X(:, :, 2) = [24 24; 22 74]; + temp = [81 87; 88 62]; + temp(:, :, 2) = [20 83; 81 18]; + X(:, :, :, 2) = temp; + Y = peak2peak (X); + T = [17 16]; + T(:, :, 2) = [2 50]; + T2 = [7 25]; + T2(:, :, 2) = [61 65]; + T(:, :, :, 2) = T2; + assert (Y, T); +***** error peak2peak () +***** error peak2peak (1, 2, 3) +***** error peak2peak (1, 1.5) +***** error peak2peak (1, 0) 8 tests, 8 passed, 0 known failure, 0 skipped -[inst/downsample.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/downsample.m -***** assert(downsample([1,2,3,4,5],2),[1,3,5]); -***** assert(downsample([1;2;3;4;5],2),[1;3;5]); -***** assert(downsample([1,2;3,4;5,6;7,8;9,10],2),[1,2;5,6;9,10]); -***** assert(downsample([1,2,3,4,5],2,1),[2,4]); -***** assert(downsample([1,2;3,4;5,6;7,8;9,10],2,1),[3,4;7,8]); -5 tests, 5 passed, 0 known failure, 0 skipped -[inst/nuttallwin.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/nuttallwin.m -***** assert (nuttallwin (1), 1) -***** assert (nuttallwin (2), zeros (2, 1), eps) -***** assert (nuttallwin (15), flipud (nuttallwin (15)), 10*eps); -***** assert (nuttallwin (16), flipud (nuttallwin (16)), 10*eps); -***** assert (nuttallwin (15), nuttallwin (15, "symmetric")); -***** assert (nuttallwin (16)(1:15), nuttallwin (15, "periodic")); -***** error nuttallwin () -***** error nuttallwin (0.5) -***** error nuttallwin (-1) -***** error nuttallwin (ones (1, 4)) -***** error nuttallwin (1, 2) -***** error nuttallwin (1, "invalid") -12 tests, 12 passed, 0 known failure, 0 skipped -[inst/triang.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/triang.m -***** assert (triang (1), 1) -***** assert (triang (2), [1; 1]/2) -***** assert (triang (3), [1; 2; 1]/2) -***** assert (triang (4), [1; 3; 3; 1]/4) +[inst/cheby1.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cheby1.m +***** error [a, b] = cheby1 () +***** error [a, b] = cheby1 (1) +***** error [a, b] = cheby1 (1, 2) +***** error [a, b] = cheby1 (1, 2, 3, 4, 5, 6) +***** error [a, b] = cheby1 (.5, 2, .2) +***** error [a, b] = cheby1 (3, 2, .2, "invalid") ***** test - x = bartlett (5); - assert (triang (3), x(2:4)); -***** error triang () -***** error triang (0.5) -***** error triang (-1) -***** error triang (ones (1, 4)) -***** error triang (1, 2) + cheby1 (3, 4, .5); + assert (isrow (ans)); +***** test + A = cheby1 (3, 4, .5); + assert (isrow (A)); +***** test + [A, B] = cheby1 (3, 4, .5); + assert (isrow (A)); + assert (isrow (B)); +***** test + [z, p, g] = cheby1 (3, 4, .5); + assert (iscolumn (z)); + assert (iscolumn (p)); + assert (isscalar (g)); +***** test + [a, b, c, d] = cheby1 (3, 4, .5); + assert (ismatrix (a)); + assert (iscolumn (b)); + assert (isrow (c)); + assert (isscalar (d)); +11 tests, 11 passed, 0 known failure, 0 skipped +[inst/tf2sos.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/tf2sos.m +***** test + B=[1 0 0 0 0 1]; A=[1 0 0 0 0 .9]; + [sos,g] = tf2sos(B,A); + [Bh,Ah] = sos2tf(sos,g); + assert({Bh,Ah},{B,A},100*eps); +1 test, 1 passed, 0 known failure, 0 skipped +[inst/shiftdata.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/shiftdata.m +***** test + X = [1 2 3; 4 5 6; 7 8 9]; + [Y, perm, shifts] = shiftdata (X, 2); + assert (Y, [1 4 7; 2 5 8; 3 6 9]); + assert (perm, [2 1]); +***** test + X = [27 42 11; 63 48 5; 67 74 93]; + X(:, :, 2) = [15 23 81; 34 60 28; 70 54 38]; + [Y, perm, shifts] = shiftdata(X, 2); + T = [27 63 67; 42 48 74; 11 5 93]; + T(:, :, 2) = [15 34 70; 23 60 54; 81 28 38]; + assert(Y, T); + assert(perm, [2 1 3]); +***** test + X = fix (rand (4, 4, 4, 4) * 100); + [Y, perm, shifts] = shiftdata (X, 3); + T = 0; + for i = 1:3 + for j = 1:3 + for k = 1:2 + for l = 1:2 + T = [T Y(k, i, j, l) - X(i, j, k ,l)]; + endfor + endfor + endfor + endfor + assert (T, zeros (size (T))); +***** error shiftdata () +***** error shiftdata (1, 2, 3) +***** error shiftdata (1, 2.5) +6 tests, 6 passed, 0 known failure, 0 skipped +[inst/butter.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/butter.m +***** shared sf, sf2, off_db + off_db = 0.5; + ## Sampling frequency must be that high to make the low pass filters pass. + sf = 6000; sf2 = sf/2; + data=[sinetone(5,sf,10,1),sinetone(10,sf,10,1),sinetone(50,sf,10,1),sinetone(200,sf,10,1),sinetone(400,sf,10,1)]; +***** test + ## Test low pass order 1 with 3dB @ 50Hz + data=[sinetone(5,sf,10,1),sinetone(10,sf,10,1),sinetone(50,sf,10,1),sinetone(200,sf,10,1),sinetone(400,sf,10,1)]; + [b, a] = butter ( 1, 50 / sf2 ); + filtered = filter ( b, a, data ); + damp_db = 20 * log10 ( max ( filtered ( end - sf : end, : ) ) ); + assert ( [ damp_db( 4 ) - damp_db( 5 ), damp_db( 1 : 3 ) ], [ 6 0 0 -3 ], off_db ) +***** test + ## Test low pass order 4 with 3dB @ 50Hz + data=[sinetone(5,sf,10,1),sinetone(10,sf,10,1),sinetone(50,sf,10,1),sinetone(200,sf,10,1),sinetone(400,sf,10,1)]; + [b, a] = butter ( 4, 50 / sf2 ); + filtered = filter ( b, a, data ); + damp_db = 20 * log10 ( max ( filtered ( end - sf : end, : ) ) ); + assert ( [ damp_db( 4 ) - damp_db( 5 ), damp_db( 1 : 3 ) ], [ 24 0 0 -3 ], off_db ) +***** test + ## Test high pass order 1 with 3dB @ 50Hz + data=[sinetone(5,sf,10,1),sinetone(10,sf,10,1),sinetone(50,sf,10,1),sinetone(200,sf,10,1),sinetone(400,sf,10,1)]; + [b, a] = butter ( 1, 50 / sf2, "high" ); + filtered = filter ( b, a, data ); + damp_db = 20 * log10 ( max ( filtered ( end - sf : end, : ) ) ); + assert ( [ damp_db( 2 ) - damp_db( 1 ), damp_db( 3 : end ) ], [ 6 -3 0 0 ], off_db ) +***** test + ## Test high pass order 4 with 3dB @ 50Hz + data=[sinetone(5,sf,10,1),sinetone(10,sf,10,1),sinetone(50,sf,10,1),sinetone(200,sf,10,1),sinetone(400,sf,10,1)]; + [b, a] = butter ( 4, 50 / sf2, "high" ); + filtered = filter ( b, a, data ); + damp_db = 20 * log10 ( max ( filtered ( end - sf : end, : ) ) ); + assert ( [ damp_db( 2 ) - damp_db( 1 ), damp_db( 3 : end ) ], [ 24 -3 0 0 ], off_db ) +***** error [a, b] = butter () +***** error [a, b] = butter (1) +***** error [a, b] = butter (1, 2, 3, 4, 5) +***** error [a, b] = butter (.5, .2) +***** error [a, b] = butter (3, .2, "invalid") +***** error [a, b] = butter (9, .6, "stop") +***** error [a, b] = butter (9, .6, "bandpass") +***** error [a, b] = butter (9, .6, "s", "high") +***** test + butter (9, .6); + assert (isrow (ans)); +***** test + A = butter (9, .6); + assert (isrow (A)); +***** test + [A, B] = butter (9, .6); + assert (isrow (A)); + assert (isrow (B)); +***** test + [z, p, g] = butter (9, .6); + assert (iscolumn (z)); + assert (iscolumn (p)); + assert (isscalar (g)); +***** test + [a, b, c, d] = butter (9, .6); + assert (ismatrix (a)); + assert (iscolumn (b)); + assert (isrow (c)); + assert (isscalar (d)); ***** demo - subplot(221); - n=7; k=(n-1)/2; t=[-k:0.1:k]/(k+1); - plot(t,1-abs(t),";continuous;",[-k:k]/(k+1),triang(n),"g*;discrete;"); - axis([-1, 1, 0, 1.3]); grid("on"); - title("comparison with continuous for odd n"); + sf = 800; sf2 = sf/2; + data=[[1;zeros(sf-1,1)],sinetone(25,sf,1,1),sinetone(50,sf,1,1),sinetone(100,sf,1,1)]; + [b,a]=butter ( 1, 50 / sf2 ); + filtered = filter(b,a,data); - subplot(222); - n=8; k=(n-1)/2; t=[-k:0.1:k]/(k+1/2); - plot(t,1+1/n-abs(t),";continuous;",[-k:k]/(k+1/2),triang(n),"g*;discrete;"); - axis([-1, 1, 0, 1.3]); grid("on"); - title("note the higher peak for even n"); + clf + subplot ( columns ( filtered ), 1, 1) + plot(filtered(:,1),";Impulse response;") + subplot ( columns ( filtered ), 1, 2 ) + plot(filtered(:,2),";25Hz response;") + subplot ( columns ( filtered ), 1, 3 ) + plot(filtered(:,3),";50Hz response;") + subplot ( columns ( filtered ), 1, 4 ) + plot(filtered(:,4),";100Hz response;") +17 tests, 17 passed, 0 known failure, 0 skipped +[inst/findpeaks.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/findpeaks.m +***** demo + t = 2*pi*linspace(0,1,1024)'; + y = sin(3.14*t) + 0.5*cos(6.09*t) + 0.1*sin(10.11*t+1/6) + 0.1*sin(15.3*t+1/3); - subplot(223); - n=7; - plot(0:n+1,bartlett(n+2),"g-*;bartlett;",triang(n),"r-+;triang;"); - axis; grid("off"); - title("n odd, triang(n)==bartlett(n+2)"); + data1 = abs(y); # Positive values + [pks idx] = findpeaks(data1); - subplot(224); - n=8; - plot(0:n+1,bartlett(n+2),"g-*;bartlett;",triang(n),"r-+;triang;"); - axis; grid("off"); - title("n even, triang(n)!=bartlett(n+2)"); -10 tests, 10 passed, 0 known failure, 0 skipped -[inst/ellipord.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/ellipord.m + data2 = y; # Double-sided + [pks2 idx2] = findpeaks(data2,"DoubleSided"); + [pks3 idx3] = findpeaks(data2,"DoubleSided","MinPeakHeight",0.5); + + subplot(1,2,1) + plot(t,data1,t(idx),data1(idx),'xm') + axis tight + subplot(1,2,2) + plot(t,data2,t(idx2),data2(idx2),"xm;>2*std;",t(idx3),data2(idx3),"or;>0.1;") + axis tight + legend("Location","NorthOutside","Orientation","horizontal") + + #---------------------------------------------------------------------------- + # Finding the peaks of smooth data is not a big deal! +***** demo + t = 2*pi*linspace(0,1,1024)'; + y = sin(3.14*t) + 0.5*cos(6.09*t) + 0.1*sin(10.11*t+1/6) + 0.1*sin(15.3*t+1/3); + + data = abs(y + 0.1*randn(length(y),1)); # Positive values + noise + [pks idx] = findpeaks(data,"MinPeakHeight",1); + + dt = t(2)-t(1); + [pks2 idx2] = findpeaks(data,"MinPeakHeight",1,... + "MinPeakDistance",round(0.5/dt)); + + subplot(1,2,1) + plot(t,data,t(idx),data(idx),'or') + subplot(1,2,2) + plot(t,data,t(idx2),data(idx2),'or') + + #---------------------------------------------------------------------------- + # Noisy data may need tuning of the parameters. In the 2nd example, + # MinPeakDistance is used as a smoother of the peaks. +***** assert (isempty (findpeaks ([1, 1, 1]))) +***** assert (isempty (findpeaks ([1; 1; 1]))) +***** test + ## Test input vector is an oversampled sinusoid with clipped peaks + x = min (3, cos (2*pi*[0:8000] ./ 600) + 2.01); + assert (! isempty (findpeaks (x))) +***** test + x = [1 10 2 2 1 9 1]; + [pks, loc] = findpeaks(x); + assert (loc, [2 6]) + assert (pks, [10 9]) +***** error findpeaks () +***** error findpeaks (1) +***** error findpeaks ([1, 2]) +***** test assert (findpeaks ([34 134 353 64 134 14 56 67 234 143 64 575 8657]), + [353 134 234]) +8 tests, 8 passed, 0 known failure, 0 skipped +[inst/sgolay.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/sgolay.m +***** test + N=2^12; + t=[0:N-1]'/N; + dt=t(2)-t(1); + w = 2*pi*50; + offset = 0.5; # 50 Hz carrier + # exponential modulation and its derivatives + d = 1+exp(-3*(t-offset)); + dd = -3*exp(-3*(t-offset)); + d2d = 9*exp(-3*(t-offset)); + d3d = -27*exp(-3*(t-offset)); + # modulated carrier and its derivatives + x = d.*sin(w*t); + dx = dd.*sin(w*t) + w*d.*cos(w*t); + d2x = (d2d-w^2*d).*sin(w*t) + 2*w*dd.*cos(w*t); + d3x = (d3d-3*w^2*dd).*sin(w*t) + (3*w*d2d-w^3*d).*cos(w*t); + + y = sgolayfilt(x,sgolay(8,41,0,dt)); + assert(norm(y-x)/norm(x),0,5e-6); + + y = sgolayfilt(x,sgolay(8,41,1,dt)); + assert(norm(y-dx)/norm(dx),0,5e-6); + + y = sgolayfilt(x,sgolay(8,41,2,dt)); + assert(norm(y-d2x)/norm(d2x),0,1e-5); + + y = sgolayfilt(x,sgolay(8,41,3,dt)); + assert(norm(y-d3x)/norm(d3x),0,1e-4); +1 test, 1 passed, 0 known failure, 0 skipped +[inst/fracshift.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/fracshift.m +***** test + d = [1.5 7/6]; + N = 1024; + t = ((0:N-1)-N/2).'; + tt = bsxfun (@minus, t, d); + err1= err2 = zeros(N/2,1); + for n = 0:N/2-1, + phi0 = 2*pi*rand; + f0 = n/N; + sigma = N/4; + x = exp(-t.^2/(2*sigma)).*sin(2*pi*f0*t + phi0); + xx = exp(-tt.^2/(2*sigma)).*sin(2*pi*f0*tt + phi0); + [y,h] = fracshift(x, d(1)); + err1(n+1) = max (abs (y - xx(:,1))); + [y,h] = fracshift(x, d(2)); + err2(n+1) = max (abs (y - xx(:,2))); + endfor + rolloff = .1; + rejection = 10^-3; + idx_inband = 1:ceil((1-rolloff)*N/2)-1; + assert (max (err1(idx_inband)) < rejection); + assert (max (err2(idx_inband)) < rejection); +***** test + N = 1024; + p = 6; + q = 7; + d1 = 64; + d2 = d1*p/q; + t = 128; + + [b a] = butter (10,.25); + n = zeros (N, 1); + n(N/2+(-t:t)) = randn(2*t+1,1); + n = filter(b,a,n); + n1 = fracshift(n,d1); + n1 = resample(n1,p,q); + n2 = resample(n,p,q); + n2 = fracshift(n2,d2); + err = abs (n2 - n1); + rejection = 10^-3; + assert(max (err) < rejection); +***** test #integer shift similar similar to non-integer + N = 1024; + t = linspace(0, 1, N).'; + x = exp(-t.^2/2/0.25^2).*sin(2*pi*10*t); + d = 10; + y = fracshift(x, d); + yh = fracshift(x, d+1e-8); + assert(y, yh, 1e-8) +***** warning fracshift([1 2 3 2 1], 3, h=0.5); #integer shift and filter provided +***** test #bug 52758 + x = [0 1 0 0 0 0 0 0]; + y = fracshift(x, 1); + assert (size(x) == size(y)) +***** test #bug 47387 + N = 1024; + t = linspace(0, 1, N).'; + x = exp(-t.^2/2/0.25^2).*sin(2*pi*10*t); + dt = 0.25; + d = dt / (t(2) - t(1)); + y = fracshift(x, d); + L = 37; + _t = (-L:L).'; + ideal_filter = sinc (_t - (d - fix (d))); + m = 2 * L; + _t = (0:m).' - (d - fix (d)); + beta = 5.6533; + _t = 2 * beta / m * sqrt (_t .* (m - _t)); + w = besseli (0, _t) / besseli (0, beta); + h = w .* ideal_filter; + yh = fracshift(x, d, h); + assert(y, yh, 1e-8) +***** demo + N = 1024; + t = linspace (0, 1, N).'; + x = exp(-t.^2/2/0.25^2).*sin(2*pi*10*t); + + dt = 0.25; + d = dt / (t(2) - t(1)); + y = fracshift(x, d); + + plot(t,y,'r-;shifted;', t, x, 'k-;original;') + axis tight + xlabel ('time') + ylabel ('signal') +6 tests, 6 passed, 0 known failure, 0 skipped +[inst/barthannwin.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/barthannwin.m +***** assert (barthannwin (1), 1) +***** assert (barthannwin (2), zeros (2, 1)) +***** error barthannwin () +***** error barthannwin (0.5) +***** error barthannwin (-1) +***** error barthannwin (ones (1, 4)) +***** error barthannwin (1, 2) +7 tests, 7 passed, 0 known failure, 0 skipped +[inst/lpc.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/lpc.m +***** demo + noise = randn (10000, 1); + x = filter (1, [1 1/2 1/4 1/8], noise); + x = x(end-4096:end); + [a, g] = lpc (x, 3); + xe = filter ([0 -a(2:end)], 1, x); + e = x - xe; + [ac, k] = xcorr (e, "coeff"); + subplot (2,1,1); plot (x(1:100), "b-", xe(1:100), "r--"); + xlabel ("sample"); ylabel ("amplitude"); legend ("original","LPC estimate"); + subplot (2,1,2); plot (k,ac,"b-"); xlabel ("lag"); + title ("autocorrelation of prediction error"); +***** demo + if !isempty ( pkg ("list", "ltfat") ) + pkg load ltfat + [sig, fs] = linus; + x = sig(13628:14428); + [a, g] = lpc (x, 8); + F = round (sort (unique (abs (angle (roots (a))))) * fs / (2 * pi) ); + [h, w] = freqz (1, a, 512, "whole"); + subplot (2, 1, 1); + plot ( 1E3 * [0:1/fs:(length (x)-1)*1/fs], x); + xlabel ("time (ms)"); ylabel ("Amplitude"); + title ( "'linus' test signal" ); + subplot (2, 1, 2); + plot (w(1:256)/pi, 20*log10 (abs (h(1:256)))); + xlabel ("Normalized Frequency ({\\times \\pi} rad/sample)") + ylabel ("Magnitude (dB)") + txt = sprintf (['Signal sampling rate = %d kHz\nFormant frequencies: ' ... + '\nF1 = %d Hz\nF2 = %d Hz\nF3 = %d Hz\nF4 = %d Hz'], fs/1E3, ... + F(1), F(2), F(3), F(4)); + text (0.6, 20, txt); + endif + ## test input validation +***** error [a, g] = lpc () +***** error [a, g] = lpc (1) +***** error [a, g] = lpc (1, 1) +***** error [a, g] = lpc (1, 1, 1) +***** error [a, g] = lpc (1:10, 0) +***** error [a, g] = lpc (1:10, 10) +***** error [a, g] = lpc (1:10, 0.5) +***** error [a, g] = lpc (1:10, 1, [1 2]) +***** test + x = [1:4 4:-1:1]; + [a, g] = lpc (x, 5); + assert (a, [1.0 -1.823903 1.101798 -0.405738 0.521153 -0.340032], 1e-6) + assert (g, 0.272194, 1e-6) +9 tests, 9 passed, 0 known failure, 0 skipped +[inst/kaiser.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/kaiser.m +***** demo + % use demo("kaiserord"); +***** assert (kaiser (1), 1) +***** error kaiser () +***** error kaiser (0.5) +***** error kaiser (-1) +***** error kaiser (ones (1, 4)) +***** error kaiser (1, 2, 3) +6 tests, 6 passed, 0 known failure, 0 skipped +[inst/gaussian.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/gaussian.m +***** assert (gaussian (1), 1) +***** error gaussian () +***** error gaussian (0.5) +***** error gaussian (-1) +***** error gaussian (ones (1, 4)) +***** error gaussian (1, 2, 3) +6 tests, 6 passed, 0 known failure, 0 skipped +[inst/statelevels.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/statelevels.m +***** error l = statelevels() +***** error l = statelevels("test") +***** error l = statelevels(1) +***** error l = statelevels([1 2 3], 'test') +***** error l = statelevels([1 2 3], 3, 'test') +***** error l = statelevels([1 2 3], 3, 'mode', 1) +***** error l = statelevels([1 2 3], 3, 'mode', [1 -1]) +***** shared X + t = linspace(0,2*pi*10,100); + X = square(t) + cos(t); +***** test + l = statelevels(X); + assert(l, [-1.9795 1.9800], 1e5) +***** test + [l, h] = statelevels(X); + assert(l, [-1.9795 1.9800], 1e5) + assert(sum(h), 100) + assert(length(h), 100) +***** test + [l, h, b] = statelevels(X); + assert(l, [-1.9795 1.9800], 1e5) + assert(sum(h), 100) + assert(length(h), 100) + assert(h(1), 4) + assert(h(2), 2) + assert(h(4), 1) + assert(h(11), 0) + assert(b(1), -1.9795, 1e5) + assert(b(2), -1.9395, 1e5) +***** test + [l, h, b] = statelevels(X, 100); + assert(l, [-1.9795 1.9800], 1e5) + assert(sum(h), 100) + assert(length(h), 100) + assert(h(1), 4) + assert(h(2), 2) + assert(h(4), 1) + assert(h(11), 0) + assert(b(1), -1.9795, 1e5) + assert(b(2), -1.9395, 1e5) +***** test + [l, h, b] = statelevels(X, 50); + assert(l, [-1.9595 1.9600], 1e5) + assert(sum(h), 100) + assert(length(h), 50) + assert(h(1), 6) + assert(h(2), 3) + assert(h(4), 2) + assert(h(11), 1) + assert(b(1), -1.9595, 1e5) + assert(b(2), -1.8795, 1e5) +***** test + [l, h, b] = statelevels(X, 100, 'mode'); + assert(l, [-1.9795 1.9800], 1e5) + assert(sum(h), 100) + assert(length(h), 100) + assert(h(1), 4) + assert(h(2), 2) + assert(h(4), 1) + assert(h(11), 0) + assert(b(1), -1.9795, 1e5) + assert(b(2), -1.9395, 1e5) +***** test + [l, h, b] = statelevels(X, 100, 'mean'); + assert(l, [-1.0090 0.9532], 1e5) + assert(sum(h), 100) + assert(length(h), 100) + assert(h(1), 4) + assert(h(2), 2) + assert(h(4), 1) + assert(h(11), 0) + assert(b(1), -1.9795, 1e5) + assert(b(2), -1.9395, 1e5) +***** test + [l, h, b] = statelevels(X, 100, 'mode', [-1.8 1.0]); + assert(l, [-1.7860 0.0060], 1e5) + assert(sum(h), 64) + assert(length(h), 100) + assert(h(1), 1) + assert(h(2), 1) + assert(h(3), 0) + assert(b(1), -1.7860, 1e5) + assert(b(2), -1.7580, 1e5) +***** demo + # Generate test signal + t = linspace(0,2*pi*10,100); + X = square(t) + cos(t); + # plot the waveform and provide the levels + statelevels(X) +15 tests, 15 passed, 0 known failure, 0 skipped +[inst/vco.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/vco.m +***** error vco +***** error vco([1 2]) +2 tests, 2 passed, 0 known failure, 0 skipped +[inst/filtfilt.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/filtfilt.m +***** error filtfilt (); +***** error filtfilt (1, 2, 3, 4); +***** error filtfilt ([0.28, 0.71, 0.28], 1, rand ()) +***** error filtfilt ([0.28, 0.71, 0.28], 1, rand (6, 1)) +***** test + randn('state',0); + r = randn(1,200); + [b,a] = butter(10, [.2, .25]); + yfb = filtfilt(b, a, r); + assert (size(r), size(yfb)); + assert (mean(abs(yfb)) < 1e3); + assert (mean(abs(yfb)) < mean(abs(r))); + ybf = fliplr(filtfilt(b, a, fliplr(r))); + assert (mean(abs(ybf)) < 1e3); + assert (mean(abs(ybf)) < mean(abs(r))); +***** test + randn('state',0); + r = randn(1,1000); + s = 10 * sin(pi * 4e-2 * (1:length(r))); + [b,a] = cheby1(2, .5, [4e-4 8e-2]); + y = filtfilt(b, a, r+s); + assert (size(r), size(y)); + assert (mean(abs(y)) < 1e3); + assert (corr(s(250:750)(:), y(250:750)(:)) > .95) + [b,a] = butter(2, [4e-4 8e-2]); + yb = filtfilt(b, a, r+s); + assert (mean(abs(yb)) < 1e3); + assert (corr(y(:), yb(:)) > .99) +***** test + randn('state',0); + r = randn(1,1000); + s = 10 * sin(pi * 4e-2 * (1:length(r))); + [b,a] = butter(2, [4e-4 8e-2]); + y = filtfilt(b, a, [r.' s.']); + yr = filtfilt(b, a, r); + ys = filtfilt(b, a, s); + assert (y, [yr.' ys.']); + y2 = filtfilt(b.', a.', [r.' s.']); + assert (y, y2); +7 tests, 7 passed, 0 known failure, 0 skipped +[inst/bohmanwin.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/bohmanwin.m +***** assert (bohmanwin (1), 1) +***** assert (bohmanwin (2), zeros (2, 1)) +***** error bohmanwin () +***** error bohmanwin (0.5) +***** error bohmanwin (-1) +***** error bohmanwin (ones (1, 4)) +***** error bohmanwin (1, 2) +7 tests, 7 passed, 0 known failure, 0 skipped +[inst/resample.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/resample.m +***** test + N=512; + p=3; q=5; + r=p/q; + NN=ceil(r*N); + t=0:N-1; + tt=0:NN-1; + err=zeros(N/2,1); + for n = 0:N/2-1, + phi0=2*pi*rand; + f0=n/N; + x=sin(2*pi*f0*t' + phi0); + [y,h]=resample(x,p,q); + xx=sin(2*pi*f0/r*tt' + phi0); + t0=ceil((length(h)-1)/2/q); + idx=t0+1:NN-t0; + err(n+1)=max(abs(y(idx)-xx(idx))); + endfor; + rolloff=.1; + rejection=10^-3; + idx_inband=1:ceil((1-rolloff/2)*r*N/2)-1; + assert(max(err(idx_inband))>>>> /build/reproducible-path/octave-signal-1.4.5/inst/buttord.m ***** demo fs = 44100; - Npts = fs; + Npts = fs / 2; fpass = 4000; - fstop = 13713; - Rpass = 3; - Rstop = 40; - Wpass = 2/fs * fpass; - Wstop = 2/fs * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) - [b, a] = ellip (n, Rpass, Rstop, Wn); - f = 0:fs/2; - W = f * (2 * pi / fs); - H = freqz (b, a, W); + fstop = 10987; + Rpass = 1; + Rstop = 26; + Wpass = 2 / fs * fpass; + Wstop = 2 / fs * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) + [b, a] = butter (n, Wn_p); + f = 8000:12000; + W = 2 * pi * f; + [H, f] = freqz (b, a, Npts, fs); plot (f, 20 * log10 (abs (H))); + title ("Digital Butterworth low-pass : matching pass band"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_lp_pass_x = [f(2) , fpass(1), fpass(1)]; outline_lp_pass_y = [-Rpass, -Rpass , -80]; outline_lp_stop_x = [f(2) , fstop(1), fstop(1), max(f)]; outline_lp_stop_y = [0 , 0 , -Rstop , -Rstop]; - hold on - plot (outline_lp_pass_x, outline_lp_pass_y, "m", outline_lp_stop_x, outline_lp_stop_y, "m"); + hold on; + plot (outline_lp_pass_x, outline_lp_pass_y, "m"); + plot (outline_lp_stop_x, outline_lp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("2nd order digital elliptical low-pass (without margin)"); ***** demo fs = 44100; - Npts = fs; + Npts = fs / 2; fpass = 4000; - fstop = 13712; - Rpass = 3; - Rstop = 40; - Wpass = 2/fs * fpass; - Wstop = 2/fs * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) - [b, a] = ellip (n, Rpass, Rstop, Wn); - f = 0:fs/2; - W = f * (2 * pi / fs); - H = freqz (b, a, W); + fstop = 10987; + Rpass = 1; + Rstop = 26; + Wpass = 2 / fs * fpass; + Wstop = 2 / fs * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) + [b, a] = butter (n, Wn_s); + f = 8000:12000; + W = 2 * pi * f; + [H, f] = freqz (b, a, Npts, fs); plot (f, 20 * log10 (abs (H))); + title ("Digital Butterworth low-pass : matching stop band"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_lp_pass_x = [f(2) , fpass(1), fpass(1)]; outline_lp_pass_y = [-Rpass, -Rpass , -80]; outline_lp_stop_x = [f(2) , fstop(1), fstop(1), max(f)]; outline_lp_stop_y = [0 , 0 , -Rstop , -Rstop]; - hold on - plot (outline_lp_pass_x, outline_lp_pass_y, "m", outline_lp_stop_x, outline_lp_stop_y, "m"); + hold on; + plot (outline_lp_pass_x, outline_lp_pass_y, "m"); + plot (outline_lp_stop_x, outline_lp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("3rd order digital elliptical low-pass (just exceeds 2nd order i.e. large margin)"); ***** demo fs = 44100; - Npts = fs; + Npts = fs / 2; fstop = 4000; - fpass = 13713; - Rpass = 3; - Rstop = 40; - Wpass = 2/fs * fpass; - Wstop = 2/fs * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) - [b, a] = ellip (n, Rpass, Rstop, Wn, "high"); - f = 0:fs/2; - W = f * (2 * pi / fs); - H = freqz (b, a, W); + fpass = 10987; + Rpass = 1; + Rstop = 26; + Wpass = 2 / fs * fpass; + Wstop = 2 / fs * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) + [b, a] = butter (n, Wn_p, "high"); + f = 8000:12000; + W = 2 * pi * f; + [H, f] = freqz (b, a, Npts, fs); plot (f, 20 * log10 (abs (H))); + title ("Digital Butterworth high-pass : matching pass band"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_hp_pass_x = [fpass(1), fpass(1), max(f)]; outline_hp_pass_y = [-80 , -Rpass , -Rpass]; outline_hp_stop_x = [min(f) , fstop(1), fstop(1), max(f)]; outline_hp_stop_y = [-Rstop , -Rstop , 0 , 0 ]; - hold on - plot (outline_hp_pass_x, outline_hp_pass_y, "m", outline_hp_stop_x, outline_hp_stop_y, "m"); + hold on; + plot (outline_hp_pass_x, outline_hp_pass_y, "m"); + plot (outline_hp_stop_x, outline_hp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("2nd order digital elliptical high-pass (without margin)"); ***** demo fs = 44100; - Npts = fs; + Npts = fs / 2; fstop = 4000; - fpass = 13712; - Rpass = 3; - Rstop = 40; - Wpass = 2/fs * fpass; - Wstop = 2/fs * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) - [b, a] = ellip (n, Rpass, Rstop, Wn, "high"); - f = 0:fs/2; - W = f * (2 * pi / fs); - H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))); + fpass = 10987; + Rpass = 1; + Rstop = 26; + Wpass = 2 / fs * fpass; + Wstop = 2 / fs * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) + [b, a] = butter (n, Wn_s, "high"); + f = 8000:12000; + W = 2 * pi * f; + [H, f] = freqz (b, a, Npts, fs); + plot (f, 20 * log10 (abs (H))) + title ("Digital Butterworth high-pass : matching stop band"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_hp_pass_x = [fpass(1), fpass(1), max(f)]; outline_hp_pass_y = [-80 , -Rpass , -Rpass]; outline_hp_stop_x = [min(f) , fstop(1), fstop(1), max(f)]; outline_hp_stop_y = [-Rstop , -Rstop , 0 , 0 ]; - hold on - plot (outline_hp_pass_x, outline_hp_pass_y, "m", outline_hp_stop_x, outline_hp_stop_y, "m"); + hold on; + plot (outline_hp_pass_x, outline_hp_pass_y, "m"); + plot (outline_hp_stop_x, outline_hp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("3rd order digital elliptical high-pass (just exceeds 2nd order i.e. large margin)"); ***** demo fs = 44100; - Npts = fs; fpass = [9500 9750]; - fstop = [8500 10261]; - Rpass = 3; - Rstop = 40; - Wpass = 2/fs * fpass; - Wstop = 2/fs * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) - [b, a] = ellip (n, Rpass, Rstop, Wn); - f = 5000:15000; + fstop = [8500 10051]; + Rpass = 1; + Rstop = 26; + Wpass = 2 / fs * fpass; + Wstop = 2 / fs * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) + [b, a] = butter (n, Wn_p); + f = (8000:12000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Digital Butterworth band-pass : matching pass band, limit on upper freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; - hold on - plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") - xlim ([f(1), f(end)]); + outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... + -Rstop , -Rstop]; + hold on; + plot (outline_bp_pass_x, outline_bp_pass_y, "m"); + plot (outline_bp_stop_x, outline_bp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("4th order digital elliptical band-pass (without margin) limitation on upper freq"); ***** demo fs = 44100; - Npts = fs; fpass = [9500 9750]; - fstop = [9000 10700]; - Rpass = 3; - Rstop = 40; - Wpass = 2/fs * fpass; - Wstop = 2/fs * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) - [b, a] = ellip (n, Rpass, Rstop, Wn); - f = 5000:15000; + fstop = [8500 10051]; + Rpass = 1; + Rstop = 26; + Wpass = 2 / fs * fpass; + Wstop = 2 / fs * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) + [b, a] = butter (n, Wn_s); + f = (8000:12000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Digital Butterworth band-pass : matching stop band, limit on upper freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; - hold on - plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") - xlim ([f(1), f(end)]); + outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... + -Rstop , -Rstop]; + hold on; + plot (outline_bp_pass_x, outline_bp_pass_y, "m"); + plot (outline_bp_stop_x, outline_bp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("4th order digital elliptical band-pass (without margin) limitation on lower freq"); ***** demo fs = 44100; - Npts = fs; fpass = [9500 9750]; - fstop = [8500 10260]; - Rpass = 3; - Rstop = 40; - Wpass = 2/fs * fpass; - Wstop = 2/fs * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) - [b, a] = ellip (n, Rpass, Rstop, Wn); - f = 5000:15000; + fstop = [9204 10700]; + Rpass = 1; + Rstop = 26; + Wpass = 2 / fs * fpass; + Wstop = 2 / fs * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) + [b, a] = butter (n, Wn_p); + f = (8000:12000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Digital Butterworth band-pass : matching pass band, limit on lower freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; - hold on - plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") - xlim ([f(1), f(end)]); + outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... + -Rstop , -Rstop]; + hold on; + plot (outline_bp_pass_x, outline_bp_pass_y, "m"); + plot (outline_bp_stop_x, outline_bp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("6th order digital elliptical band-pass (just exceeds 4th order i.e. large margin) limitation on upper freq"); ***** demo fs = 44100; - Npts = fs; fpass = [9500 9750]; - fstop = [9001 10700]; - Rpass = 3; - Rstop = 40; - Wpass = 2/fs * fpass; - Wstop = 2/fs * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) - [b, a] = ellip (n, Rpass, Rstop, Wn); - f = 5000:15000; + fstop = [9204 10700]; + Rpass = 1; + Rstop = 26; + Wpass = 2 / fs * fpass; + Wstop = 2 / fs * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) + [b, a] = butter (n, Wn_s); + f = (8000:12000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Digital Butterworth band-pass : matching stop band, limit on lower freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; - hold on - plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") - xlim ([f(1), f(end)]); + outline_bp_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... + -Rstop , -Rstop]; + hold on; + plot (outline_bp_pass_x, outline_bp_pass_y, "m"); + plot (outline_bp_stop_x, outline_bp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("6th order digital elliptical band-pass (just exceeds 4th order i.e. large margin) limitation on lower freq"); ***** demo fs = 44100; - Npts = fs; - fstop = [9875 10126.5823]; - fpass = [8500 11073]; + fstop = [9875, 10126.5823]; + fpass = [8500 10833]; Rpass = 0.5; Rstop = 40; - Wpass = 2/fs * fpass; - Wstop = 2/fs * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) - [b, a] = ellip (n, Rpass, Rstop, Wn, "stop"); - f = 5000:15000; + Wpass = 2 / fs * fpass; + Wstop = 2 / fs * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) + [b, a] = butter (n, Wn_p, "stop"); + f = (8000:12000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Digital Butterworth notch : matching pass band, limit on upper freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_notch_pass_x_a = [min(f) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; - hold on - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") - xlim ([f(1), f(end)]); + outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... + 0 , 0 ]; + hold on; + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); + plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); + plot (outline_notch_stop_x, outline_notch_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("4th order digital elliptical notch (without margin) limit on upper freq"); ***** demo fs = 44100; - Npts = fs; - fstop = [9875 10126.5823]; - fpass = [8952 12000]; + fstop = [9875, 10126.5823]; + fpass = [8500 10833]; Rpass = 0.5; Rstop = 40; - Wpass = 2/fs * fpass; - Wstop = 2/fs * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) - [b, a] = ellip (n, Rpass, Rstop, Wn, "stop"); - f = 5000:15000; + Wpass = 2 / fs * fpass; + Wstop = 2 / fs * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) + [b, a] = butter (n, Wn_s, "stop"); + f = (8000:12000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Digital Butterworth notch : matching stop band, limit on upper freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_notch_pass_x_a = [min(f) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; - hold on - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") - xlim ([f(1), f(end)]); + outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... + 0 , 0 ]; + hold on; + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); + plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); + plot (outline_notch_stop_x, outline_notch_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("4th order digital elliptical notch (without margin) limit on lower freq"); ***** demo fs = 44100; - Npts = fs; - fstop = [9875 10126.5823]; - fpass = [8500 11072]; + fstop = [9875, 10126.5823]; + fpass = [9183 11000]; Rpass = 0.5; Rstop = 40; - Wpass = 2/fs * fpass; - Wstop = 2/fs * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) - [b, a] = ellip (n, Rpass, Rstop, Wn, "stop"); - f = 5000:15000; + Wpass = 2 / fs * fpass; + Wstop = 2 / fs * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) + [b, a] = butter (n, Wn_p, "stop"); + f = (8000:12000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Digital Butterworth notch : matching pass band, limit on lower freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_notch_pass_x_a = [min(f) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; - hold on - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") - xlim ([f(1), f(end)]); + outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... + 0 , 0 ]; + hold on; + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); + plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); + plot (outline_notch_stop_x, outline_notch_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("6th order digital elliptical notch (just exceeds 4th order) limit on upper freq"); ***** demo fs = 44100; - Npts = fs; - fstop = [9875 10126.5823]; - fpass = [8953 12000]; + fstop = [9875, 10126.5823]; + fpass = [9183 11000]; Rpass = 0.5; Rstop = 40; - Wpass = 2/fs * fpass; - Wstop = 2/fs * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop) - [b, a] = ellip (n, Rpass, Rstop, Wn, "stop"); - f = 5000:15000; + Wpass = 2 / fs * fpass; + Wstop = 2 / fs * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop) + [b, a] = butter (n, Wn_s, "stop"); + f = (8000:12000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Digital Butterworth notch : matching stop band, limit on lower freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_notch_pass_x_a = [min(f) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; - hold on - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") - xlim ([f(1), f(end)]); + outline_notch_stop_x = [min(f) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... + 0 , 0 ]; + hold on; + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); + plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); + plot (outline_notch_stop_x, outline_notch_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("6th order digital elliptical notch (just exceeds 4th order) limit on lower freq"); ***** demo fpass = 4000; - fstop = 20224; - Rpass = 3; - Rstop = 40; - Wpass = 2*pi * fpass; - Wstop = 2*pi * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = ellip (n, Rpass, Rstop, Wn, "s"); + fstop = 13583; + Rpass = 1; + Rstop = 26; + Wpass = 2 * pi * fpass; + Wstop = 2 * pi * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = butter (n, Wn_p, "s"); f = 1000:10:100000; - W = 2*pi * f; + W = 2 * pi * f; H = freqs (b, a, W); - semilogx(f, 20 * log10 (abs (H))) + semilogx (f, 20 * log10 (abs (H))) + title ("Analog Butterworth low-pass : matching pass band"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_lp_pass_x = [f(2) , fpass(1), fpass(1)]; outline_lp_pass_y = [-Rpass, -Rpass , -80]; outline_lp_stop_x = [f(2) , fstop(1), fstop(1), max(f)]; outline_lp_stop_y = [0 , 0 , -Rstop , -Rstop]; - hold on - plot (outline_lp_pass_x, outline_lp_pass_y, "m", outline_lp_stop_x, outline_lp_stop_y, "m") + hold on; + plot (outline_lp_pass_x, outline_lp_pass_y, "m"); + plot (outline_lp_stop_x, outline_lp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("2nd order analog elliptical low-pass (without margin)"); ***** demo fpass = 4000; - fstop = 20223; - Rpass = 3; - Rstop = 40; - Wpass = 2*pi * fpass; - Wstop = 2*pi * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = ellip (n, Rpass, Rstop, Wn, "s"); + fstop = 13583; + Rpass = 1; + Rstop = 26; + Wpass = 2 * pi * fpass; + Wstop = 2 * pi * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = butter (n, Wn_s, "s"); f = 1000:10:100000; - W = 2*pi * f; + W = 2 * pi * f; H = freqs (b, a, W); - semilogx (f, 20 * log10 (abs (H))) + semilogx (f, 20 * log10 (abs (H))); + title ("Analog Butterworth low-pass : matching stop band"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_lp_pass_x = [f(2) , fpass(1), fpass(1)]; outline_lp_pass_y = [-Rpass, -Rpass , -80]; outline_lp_stop_x = [f(2) , fstop(1), fstop(1), max(f)]; outline_lp_stop_y = [0 , 0 , -Rstop , -Rstop]; - hold on - plot (outline_lp_pass_x, outline_lp_pass_y, "m", outline_lp_stop_x, outline_lp_stop_y, "m") + hold on; + plot (outline_lp_pass_x, outline_lp_pass_y, "m"); + plot (outline_lp_stop_x, outline_lp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("3rd order analog elliptical low-pass (just exceeds 2nd order i.e. large margin)"); ***** demo fstop = 4000; - fpass = 20224; - Rpass = 3; - Rstop = 40; - Wpass = 2*pi * fpass; - Wstop = 2*pi * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = ellip (n, Rpass, Rstop, Wn, "high", "s"); + fpass = 13583; + Rpass = 1; + Rstop = 26; + Wpass = 2 * pi * fpass; + Wstop = 2 * pi * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = butter (n, Wn_p, "high", "s"); f = 1000:10:100000; - W = 2*pi * f; + W = 2 * pi * f; H = freqs (b, a, W); - semilogx (f, 20 * log10 (abs (H))) + semilogx (f, 20 * log10 (abs (H))); + title ("Analog Butterworth high-pass : matching pass band"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_hp_pass_x = [fpass(1), fpass(1), max(f)]; outline_hp_pass_y = [-80 , -Rpass , -Rpass]; outline_hp_stop_x = [f(2) , fstop(1), fstop(1), max(f)]; outline_hp_stop_y = [-Rstop , -Rstop , 0 , 0 ]; - hold on - plot (outline_hp_pass_x, outline_hp_pass_y, "m", outline_hp_stop_x, outline_hp_stop_y, "m") + hold on; + plot (outline_hp_pass_x, outline_hp_pass_y, "m"); + plot (outline_hp_stop_x, outline_hp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("2nd order analog elliptical high-pass (without margin)"); ***** demo fstop = 4000; - fpass = 20223; - Rpass = 3; - Rstop = 40; - Wpass = 2*pi * fpass; - Wstop = 2*pi * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = ellip (n, Rpass, Rstop, Wn, "high", "s"); + fpass = 13583; + Rpass = 1; + Rstop = 26; + Wpass = 2 * pi * fpass; + Wstop = 2 * pi * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = butter (n, Wn_s, "high", "s"); f = 1000:10:100000; - W = 2*pi * f; + W = 2 * pi * f; H = freqs (b, a, W); - semilogx (f, 20 * log10 (abs (H))) + semilogx (f, 20 * log10 (abs (H))); + title ("Analog Butterworth high-pass : matching stop band"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_hp_pass_x = [fpass(1), fpass(1), max(f)]; outline_hp_pass_y = [-80 , -Rpass , -Rpass]; outline_hp_stop_x = [f(2) , fstop(1), fstop(1), max(f)]; outline_hp_stop_y = [-Rstop , -Rstop , 0 , 0 ]; - hold on - plot (outline_hp_pass_x, outline_hp_pass_y, "m", outline_hp_stop_x, outline_hp_stop_y, "m") + hold on; + plot (outline_hp_pass_x, outline_hp_pass_y, "m"); + plot (outline_hp_stop_x, outline_hp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("3rd order analog elliptical high-pass (just exceeds 2nd order i.e. large margin)"); ***** demo - fpass = [9875 10126.5823]; - fstop = [9000 10657]; - Rpass = 3; - Rstop = 40; - fcenter = sqrt (fpass(1) * fpass(2)); - Wpass = 2*pi * fpass; - Wstop = 2*pi * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = ellip (n, Rpass, Rstop, Wn, "s"); - f = 5000:15000; - W = 2*pi * f; + fpass = [9875, 10126.5823]; + fstop = [9000, 10436]; + Rpass = 1; + Rstop = 26; + Wpass = 2 * pi * fpass; + Wstop = 2 * pi * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = butter (n, Wn_p, "s"); + f = 8000:12000; + W = 2 * pi * f; H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Analog Butterworth band-pass : matching pass band, limit on upper freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; - hold on - plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") - xlim ([f(1), f(end)]); + outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... + -Rstop , -Rstop]; + hold on; + plot (outline_bp_pass_x, outline_bp_pass_y, "m"); + plot (outline_bp_stop_x, outline_bp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("4th order analog elliptical band-pass (without margin) limitation on upper freq"); ***** demo - fpass = [9875 10126.5823]; - fstop = [9384 12000]; - Rpass = 3; - Rstop = 40; - fcenter = sqrt (fpass(1) * fpass(2)); - Wpass = 2*pi * fpass; - Wstop = 2*pi * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = ellip (n, Rpass, Rstop, Wn, "s"); - f = 5000:15000; - W = 2*pi * f; + fpass = [9875, 10126.5823]; + fstop = [9000, 10436]; + Rpass = 1; + Rstop = 26; + Wpass = 2 * pi * fpass; + Wstop = 2 * pi * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = butter (n, Wn_s, "s"); + f = 8000:12000; + W = 2 * pi * f; H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Analog Butterworth band-pass : matching stop band, limit on upper freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; - hold on - plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") - xlim ([f(1), f(end)]); + outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... + -Rstop , -Rstop]; + hold on; + plot (outline_bp_pass_x, outline_bp_pass_y, "m"); + plot (outline_bp_stop_x, outline_bp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("4th order analog elliptical band-pass (without margin) limitation on lower freq"); ***** demo - fpass = [9875 10126.5823]; - fstop = [9000 10656]; - Rpass = 3; - Rstop = 40; - fcenter = sqrt (fpass(1) * fpass(2)); - Wpass = 2*pi * fpass; - Wstop = 2*pi * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = ellip (n, Rpass, Rstop, Wn, "s"); - f = 5000:15000; - W = 2*pi * f; + fpass = [9875, 10126.5823]; + fstop = [9582, 11000]; + Rpass = 1; + Rstop = 26; + Wpass = 2 * pi * fpass; + Wstop = 2 * pi * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = butter (n, Wn_p, "s"); + f = 8000:12000; + W = 2 * pi * f; H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Analog Butterworth band-pass : matching pass band, limit on lower freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; - hold on - plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") - xlim ([f(1), f(end)]); + outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... + -Rstop , -Rstop]; + hold on; + plot (outline_bp_pass_x, outline_bp_pass_y, "m"); + plot (outline_bp_stop_x, outline_bp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("6th order analog elliptical band-pass (just exceeds 4th order i.e. large margin) limitation on upper freq"); ***** demo - fpass = [9875 10126.5823]; - fstop = [9385 12000]; - Rpass = 3; - Rstop = 40; - fcenter = sqrt (fpass(1) * fpass(2)); - Wpass = 2*pi * fpass; - Wstop = 2*pi * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = ellip (n, Rpass, Rstop, Wn, "s"); - f = 5000:15000; - W = 2*pi * f; + fpass = [9875, 10126.5823]; + fstop = [9582, 11000]; + Rpass = 1; + Rstop = 26; + Wpass = 2 * pi * fpass; + Wstop = 2 * pi * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = butter (n, Wn_s, "s"); + f = 8000:12000; + W = 2 * pi * f; H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Analog Butterworth band-pass : matching stop band, limit on lower freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_bp_pass_x = [fpass(1), fpass(1), fpass(2), fpass(2)]; outline_bp_pass_y = [-80 , -Rpass , -Rpass , -80]; - outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , -Rstop , -Rstop]; - hold on - plot (outline_bp_pass_x, outline_bp_pass_y, "m", outline_bp_stop_x, outline_bp_stop_y, "m") - xlim ([f(1), f(end)]); + outline_bp_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_bp_stop_y = [-Rstop , -Rstop , 0 , 0 , ... + -Rstop , -Rstop]; + hold on; + plot (outline_bp_pass_x, outline_bp_pass_y, "m"); + plot (outline_bp_stop_x, outline_bp_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("6th order analog elliptical band-pass (just exceeds 4th order i.e. large margin) limitation on lower freq"); ***** demo fstop = [9875 10126.5823]; - fpass = [9000 10657]; - Rpass = 3; - Rstop = 40; - fcenter = sqrt (fpass(1) * fpass(2)); - Wpass = 2*pi * fpass; - Wstop = 2*pi * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = ellip (n, Rpass, Rstop, Wn, "stop", "s"); - f = 5000:15000; - W = 2*pi * f; + fpass = [9000 10436]; + Rpass = 1; + Rstop = 26; + Wpass = 2 * pi * fpass; + Wstop = 2 * pi * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = butter (n, Wn_p, "stop", "s"); + f = 8000:12000; + W = 2 * pi * f; H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Analog Butterworth notch : matching pass band, limit on upper freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_notch_pass_x_a = [f(2) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; - hold on - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") - xlim ([f(1), f(end)]); + outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... + 0 , 0 ]; + hold on; + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); + plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); + plot (outline_notch_stop_x, outline_notch_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("4th order analog elliptical notch (without margin) limit on upper freq"); ***** demo fstop = [9875 10126.5823]; - fpass = [9384 12000]; - Rpass = 3; - Rstop = 40; - fcenter = sqrt (fpass(1) * fpass(2)); - Wpass = 2*pi * fpass; - Wstop = 2*pi * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = ellip (n, Rpass, Rstop, Wn, "stop", "s"); - f = 5000:15000; - W = 2*pi * f; + fpass = [9000 10436]; + Rpass = 1; + Rstop = 26; + Wpass = 2 * pi * fpass; + Wstop = 2 * pi * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = butter (n, Wn_s, "stop", "s"); + f = 8000:12000; + W = 2 * pi * f; H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Analog Butterworth notch : matching stop band, limit on upper freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_notch_pass_x_a = [f(2) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; - hold on - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") - xlim ([f(1), f(end)]); + outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... + 0 , 0 ]; + hold on; + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); + plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); + plot (outline_notch_stop_x, outline_notch_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("4th order analog elliptical notch (without margin) limit on lower freq"); ***** demo fstop = [9875 10126.5823]; - fpass = [9000 10656]; - Rpass = 3; - Rstop = 40; - fcenter = sqrt (fpass(1) * fpass(2)); - Wpass = 2*pi * fpass; - Wstop = 2*pi * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = ellip (n, Rpass, Rstop, Wn, "stop", "s"); - f = 5000:15000; - W = 2*pi * f; + fpass = [9582 11000]; + Rpass = 1; + Rstop = 26; + Wpass = 2 * pi * fpass; + Wstop = 2 * pi * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = butter (n, Wn_p, "stop", "s"); + f = 8000:12000; + W = 2 * pi * f; H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Analog Butterworth notch : matching pass band, limit on lower freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_notch_pass_x_a = [f(2) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; - hold on - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") - xlim ([f(1), f(end)]); + outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... + 0 , 0 ]; + hold on; + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); + plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); + plot (outline_notch_stop_x, outline_notch_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("6th order analog elliptical notch (just exceeds 4th order) limit on upper freq"); ***** demo fstop = [9875 10126.5823]; - fpass = [9385 12000]; - Rpass = 3; - Rstop = 40; - fcenter = sqrt (fpass(1) * fpass(2)); - Wpass = 2*pi * fpass; - Wstop = 2*pi * fstop; - [n, Wn] = ellipord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = ellip (n, Rpass, Rstop, Wn, "stop", "s"); - f = 5000:15000; - W = 2*pi * f; + fpass = [9582 11000]; + Rpass = 1; + Rstop = 26; + Wpass = 2 * pi * fpass; + Wstop = 2 * pi * fstop; + [n, Wn_p, Wn_s] = buttord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = butter (n, Wn_s, "stop", "s"); + f = 8000:12000; + W = 2 * pi * f; H = freqs (b, a, W); - plot (f, 20 * log10 (abs (H))) + plot (f, 20 * log10 (abs (H))); + title ("Analog Butterworth notch : matching stop band, limit on lower freq"); + xlabel ("Frequency (Hz)"); + ylabel ("Attenuation (dB)"); + grid on; outline_notch_pass_x_a = [f(2) , fpass(1), fpass(1)]; outline_notch_pass_x_b = [fpass(2), fpass(2), max(f)]; outline_notch_pass_y_a = [-Rpass , -Rpass , -80]; outline_notch_pass_y_b = [-80 , -Rpass , -Rpass]; - outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), fstop(2), max(f)]; - outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , 0 , 0 ]; - hold on - plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m", outline_notch_pass_x_b, outline_notch_pass_y_b, "m", outline_notch_stop_x, outline_notch_stop_y, "m") - xlim ([f(1), f(end)]); + outline_notch_stop_x = [f(2) , fstop(1), fstop(1), fstop(2), ... + fstop(2), max(f)]; + outline_notch_stop_y = [0 , 0 , -Rstop , -Rstop , ... + 0 , 0 ]; + hold on; + plot (outline_notch_pass_x_a, outline_notch_pass_y_a, "m"); + plot (outline_notch_pass_x_b, outline_notch_pass_y_b, "m"); + plot (outline_notch_stop_x, outline_notch_stop_y, "m"); ylim ([-80, 0]); - grid on - xlabel ("Frequency (Hz)"); - ylabel ("Attenuation (dB)"); - title ("6th order analog elliptical notch (just exceeds 4th order) limit on lower freq"); ***** test # Analog band-pass - [n, Wn] = ellipord (2 * pi * [9875, 10126.5823], ... - 2 * pi * [9000, 10657], 3, 40, "s"); - assert (n, 2); - assert (round (Wn), [62046, 63627]); + [n, Wn_p, Wn_s] = buttord (2 * pi * [9875, 10126.5823], ... + 2 * pi * [9000, 10436], 1, 26, "s"); + assert (n, 4); + assert (round (Wn_p), [61903, 63775]); + assert (round (Wn_s), [61575, 64114]); ***** test # Analog band-pass - [n, Wn] = ellipord (2 * pi * [9875, 10126.5823], ... - 2 * pi * [9384, 12000], 3, 40, "s"); - assert (n, 2); - assert (round (Wn), [62046, 63627]); + [n, Wn_p, Wn_s] = buttord (2 * pi * [9875, 10126.5823], ... + 2 * pi * [9582, 11000], 1, 26, "s"); + assert (n, 4); + assert (round (Wn_p), [61903, 63775]); + assert (round (Wn_s), [61575, 64115]); ***** test # Analog band-pass - [n, Wn] = ellipord (2 * pi * [9875, 10126.5823], ... - 2 * pi * [9000, 10656], 3, 40, "s"); + [n, Wn_p, Wn_s] = buttord (2 * pi * [9875, 10126.5823], ... + 2 * pi * [9000, 10437], 1, 26, "s"); assert (n, 3); - assert (round (Wn), [62046, 63627]); + assert (round (Wn_p), [61850, 63830]); + assert (round (Wn_s), [61848, 63831]); ***** test # Analog band-pass - [n, Wn] = ellipord (2 * pi * [9875, 10126.5823], ... - 2 * pi * [9385, 12000], 3, 40, "s"); + [n, Wn_p, Wn_s] = buttord (2 * pi * [9875, 10126.5823], ... + 2 * pi * [9581, 11000], 1, 26, "s"); assert (n, 3); - assert (round (Wn), [62046, 63627]); + assert (round (Wn_p), [61850, 63830]); + assert (round (Wn_s), [61847, 63832]); ***** test # Analog high-pass - [n, Wn] = ellipord (2 * pi * 20224, 2 * pi * 4000, 3, 40, "s"); - assert (n, 2); - assert (round (Wn), 127071); + [n, Wn_p, Wn_s] = buttord (2 * pi * 13583, 2 * pi * 4000, 1, 26, "s"); + assert (n, 4); + assert (round (Wn_p), 72081); + assert (round (Wn_s), 53101); ***** test # Analog high-pass - [n, Wn] = ellipord (2 * pi * 20223, 2 * pi * 4000, 3, 40, "s"); + [n, Wn_p, Wn_s] = buttord (2 * pi * 13584, 2 * pi * 4000, 1, 26, "s"); assert (n, 3); - assert (round (Wn), 127065); + assert (round (Wn_p), 68140); + assert (round (Wn_s), 68138); ***** test # Analog low-pass - [n, Wn] = ellipord (2 * pi * 4000, 2 * pi * 20224, 3, 40, "s"); - assert (n, 2); - assert (round (Wn), 25133); + [n, Wn_p, Wn_s] = buttord (2 * pi * 4000, 2 * pi * 13583, 1, 26, "s"); + assert (n, 4); + assert (round (Wn_p), 29757); + assert (round (Wn_s), 40394); ***** test # Analog low-pass - [n, Wn] = ellipord (2 * pi * 4000, 2 * pi * 20223, 3, 40, "s"); + [n, Wn_p, Wn_s] = buttord (2 * pi * 4000, 2 * pi * 13584, 1, 26, "s"); assert (n, 3); - assert (round (Wn), 25133); + assert (round (Wn_p), 31481); + assert (round (Wn_s), 31482); ***** test # Analog notch (narrow band-stop) - [n, Wn] = ellipord (2 * pi * [9000, 10657], ... - 2 * pi * [9875, 10126.5823], 3, 40, "s"); - assert (n, 2); - assert (round (Wn), [58958, 66960]); + [n, Wn_p, Wn_s] = buttord (2 * pi * [9000, 10436], ... + 2 * pi * [9875, 10126.5823], 1, 26, "s"); + assert (n, 4); + assert (round (Wn_p), [60607, 65138]); + assert (round (Wn_s), [61184, 64524]); ***** test # Analog notch (narrow band-stop) - [n, Wn] = ellipord (2 * pi * [9384, 12000], ... - 2 * pi * [9875, 10126.5823], 3, 40, "s"); - assert (n, 2); - assert (round (Wn), [58961 , 66956]); + [n, Wn_p, Wn_s] = buttord (2 * pi * [9582, 11000], ... + 2 * pi * [9875, 10126.5823], 1, 26, "s"); + assert (n, 4); + assert (round (Wn_p), [60606, 65139]); + assert (round (Wn_s), [61184, 64524]); ***** test # Analog notch (narrow band-stop) - [n, Wn] = ellipord (2 * pi * [9000, 10656], ... - 2 * pi * [9875, 10126.5823], 3, 40, "s"); + [n, Wn_p, Wn_s] = buttord (2 * pi * [9000, 10437], ... + 2 * pi * [9875, 10126.5823], 1, 26, "s"); assert (n, 3); - assert (round (Wn), [58964, 66954]); + assert (round (Wn_p), [60722, 65015]); + assert (round (Wn_s), [60726, 65011]); ***** test # Analog notch (narrow band-stop) - [n, Wn] = ellipord (2 * pi * [9385, 12000], ... - 2 * pi * [9875, 10126.5823], 3, 40, "s"); + [n, Wn_p, Wn_s] = buttord (2 * pi * [9581, 11000], ... + 2 * pi * [9875, 10126.5823], 1, 26, "s"); assert (n, 3); - assert (round (Wn), [58968, 66949]); + assert (round (Wn_p), [60721, 65016]); + assert (round (Wn_s), [60726, 65011]); ***** test # Digital band-pass fs = 44100; - [n, Wn] = ellipord (2 / fs * [9500, 9750], 2 / fs * [8500, 10261], 3, 40); - Wn = Wn * fs / 2; - assert (n, 2); - assert (round (Wn), [9500, 9750]); + [n, Wn_p, Wn_s] = buttord (2 / fs * [9500, 9750], ... + 2 / fs * [8500, 10051], 1, 26); + Wn_p = Wn_p * fs / 2; + Wn_s = Wn_s * fs / 2; + assert (n, 4); + assert (round (Wn_p), [9477, 9773]); + assert (round (Wn_s), [9425, 9826]); ***** test # Digital band-pass fs = 44100; - [n, Wn] = ellipord (2 / fs * [9500, 9750], 2 / fs * [9000, 10700], 3, 40); - Wn = Wn * fs / 2; - assert (n, 2); - assert (round (Wn), [9500, 9750]); + [n, Wn_p, Wn_s] = buttord (2 / fs * [9500, 9750], ... + 2 / fs * [9204, 10700], 1, 26); + Wn_p = Wn_p * fs / 2; + Wn_s = Wn_s * fs / 2; + assert (n, 4); + assert (round (Wn_p), [9477, 9773]); + assert (round (Wn_s), [9425, 9826]); ***** test # Digital band-pass fs = 44100; - [n, Wn] = ellipord (2 / fs * [9500, 9750], 2 / fs * [8500, 10260], 3, 40); - Wn = Wn * fs / 2; + [n, Wn_p, Wn_s] = buttord (2 / fs * [9500, 9750], ... + 2 / fs * [8500, 10052], 1, 26); + Wn_p = Wn_p * fs / 2; + Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn), [9500, 9750]); + assert (round (Wn_p), [9469, 9782]); + assert (round (Wn_s), [9468, 9782]); ***** test # Digital band-pass fs = 44100; - [n, Wn] = ellipord (2 / fs * [9500, 9750], 2 / fs * [9001, 10700], 3, 40); - Wn = Wn * fs / 2; + [n, Wn_p, Wn_s] = buttord (2 / fs * [9500, 9750], ... + 2 / fs * [9203, 10700], 1, 26); + Wn_p = Wn_p * fs / 2; + Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn), [9500, 9750]); + assert (round (Wn_p), [9469, 9782]); + assert (round (Wn_s), [9468, 9782]); ***** test # Digital high-pass fs = 44100; - [n, Wn] = ellipord (2 / fs * 13713, 2 / fs * 4000, 3, 40); - Wn = Wn * fs / 2; - assert (n, 2); - assert (round (Wn), 13713); + [n, Wn_p, Wn_s] = buttord (2 / fs * 10987, 2 / fs * 4000, 1, 26); + Wn_p = Wn_p * fs / 2; + Wn_s = Wn_s * fs / 2; + assert (n, 4); + assert (round (Wn_p), 9808); + assert (round (Wn_s), 7780); ***** test # Digital high-pass fs = 44100; - [n, Wn] = ellipord (2 / fs * 13712, 2 / fs * 4000, 3, 40); - Wn = Wn * fs / 2; + [n, Wn_p, Wn_s] = buttord (2 / fs * 10988, 2 / fs * 4000, 1, 26); + Wn_p = Wn_p * fs / 2; + Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn), 13712); + assert (round (Wn_p), 9421); + assert (round (Wn_s), 9421); ***** test # Digital low-pass fs = 44100; - [n, Wn] = ellipord (2 / fs * 4000, 2 / fs * 13713, 3, 40); - Wn = Wn * fs / 2; - assert (n, 2); - assert (round (Wn), 4000); + [n, Wn_p, Wn_s] = buttord (2 / fs * 4000, 2 / fs * 10987, 1, 26); + Wn_p = Wn_p * fs / 2; + Wn_s = Wn_s * fs / 2; + assert (n, 4); + assert (round (Wn_p), 4686); + assert (round (Wn_s), 6176); ***** test # Digital low-pass fs = 44100; - [n, Wn] = ellipord (2 / fs * 4000, 2 / fs * 13712, 3, 40); - Wn = Wn * fs / 2; + [n, Wn_p, Wn_s] = buttord (2 / fs * 4000, 2 / fs * 10988, 1, 26); + Wn_p = Wn_p * fs / 2; + Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn), 4000); + assert (round (Wn_p), 4936); + assert (round (Wn_s), 4936); ***** test # Digital notch (narrow band-stop) fs = 44100; - [n, Wn] = ellipord (2 / fs * [8500, 11073], 2 / fs * [9875, 10126.5823], 0.5, 40); - Wn = Wn * fs / 2; - assert (n, 2); - assert (round (Wn), [8952, 11073]); + [n, Wn_p, Wn_s] = buttord (2 / fs * [8500, 10833], ... + 2 / fs * [9875, 10126.5823], 0.5, 40); + Wn_p = Wn_p * fs / 2; + Wn_s = Wn_s * fs / 2; + assert (n, 4); + assert (round (Wn_p), [9369, 10640]); + assert (round (Wn_s), [9605, 10400]); ***** test # Digital notch (narrow band-stop) fs = 44100; - [n, Wn] = ellipord (2 / fs * [8952, 12000], 2 / fs * [9875, 10126.5823], 0.5, 40); - Wn = Wn * fs / 2; - assert (n, 2); - assert (round (Wn), [8952, 11073]); + [n, Wn_p, Wn_s] = buttord (2 / fs * [9183, 11000], ... + 2 / fs * [9875, 10126.5823], 0.5, 40); + Wn_p = Wn_p * fs / 2; + Wn_s = Wn_s * fs / 2; + assert (n, 4); + assert (round (Wn_p), [9370, 10640]); + assert (round (Wn_s), [9605, 10400]); ***** test # Digital notch (narrow band-stop) fs = 44100; - [n, Wn] = ellipord (2 / fs * [8500, 11072], 2 / fs * [9875, 10126.5823], 0.5, 40); - Wn = Wn * fs / 2; + [n, Wn_p, Wn_s] = buttord (2 / fs * [8500, 10834], ... + 2 / fs * [9875, 10126.5823], 0.5, 40); + Wn_p = Wn_p * fs / 2; + Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn), [8953, 11072]); + assert (round (Wn_p), [9421, 10587]); + assert (round (Wn_s), [9422, 10587]); ***** test # Digital notch (narrow band-stop) fs = 44100; - [n, Wn] = ellipord (2 / fs * [8953, 12000], 2 / fs * [9875, 10126.5823], 0.5, 40); - Wn = Wn * fs / 2; + [n, Wn_p, Wn_s] = buttord (2 / fs * [9182, 11000], ... + 2 / fs * [9875, 10126.5823], 0.5, 40); + Wn_p = Wn_p * fs / 2; + Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn), [8953, 11072]); -***** error ellipord () -***** error ellipord (.1) -***** error ellipord (.1, .2) -***** error ellipord (.1, .2, 3) -***** error ellipord ([.1 .1], [.2 .2], 3, 4) -***** error ellipord ([.1 .2], [.5 .6], 3, 4) -***** error ellipord ([.1 .5], [.2 .6], 3, 4) + assert (round (Wn_p), [9421, 10587]); + assert (round (Wn_s), [9422, 10587]); +***** error buttord () +***** error buttord (.1) +***** error buttord (.1, .2) +***** error buttord (.1, .2, 3) +***** error buttord ([.1 .1], [.2 .2], 3, 4) +***** error buttord ([.1 .2], [.5 .6], 3, 4) +***** error buttord ([.1 .5], [.2 .6], 3, 4) 31 tests, 31 passed, 0 known failure, 0 skipped -[inst/gaussian.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/gaussian.m -***** assert (gaussian (1), 1) -***** error gaussian () -***** error gaussian (0.5) -***** error gaussian (-1) -***** error gaussian (ones (1, 4)) -***** error gaussian (1, 2, 3) -6 tests, 6 passed, 0 known failure, 0 skipped -[inst/gauspuls.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/gauspuls.m +[inst/upsample.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/upsample.m +***** assert(upsample([1,3,5],2),[1,0,3,0,5,0]); +***** assert(upsample([1;3;5],2),[1;0;3;0;5;0]); +***** assert(upsample([1,2;5,6;9,10],2),[1,2;0,0;5,6;0,0;9,10;0,0]); +***** assert(upsample([2,4],2,1),[0,2,0,4]); +***** assert(upsample([3,4;7,8],2,1),[0,0;3,4;0,0;7,8]); +5 tests, 5 passed, 0 known failure, 0 skipped +[inst/filtic.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/filtic.m +***** test + ## Simple low pass filter + b=[0.25 0.25]; + a=[1.0 -0.5]; + zf_ref=0.75; + zf=filtic(b,a,[1.0],[1.0]); + assert(zf,zf_ref,8*eps); + +***** test + ## Simple high pass filter + b=[0.25 -0.25]; + a=[1.0 0.5]; + zf_ref = [-0.25]; + zf=filtic(b,a,[0.0],[1.0]); + assert(zf,zf_ref,8*eps); + +***** test + ## Second order cases + [b,a]=butter(2,0.4); + N=1000; ## Long enough for filter to settle + xx=ones(1,N); + [yy,zf_ref] = filter(b,a,xx); + x=xx(N:-1:N-1); + y=yy(N:-1:N-1); + zf = filtic(b,a,y,x); + assert(zf,zf_ref,8*eps); + + xx = cos(2*pi*linspace(0,N-1,N)/8); + [yy,zf_ref] = filter(b,a,xx); + x=xx(N:-1:N-1); + y=yy(N:-1:N-1); + zf = filtic(b,a,y,x); + assert(zf,zf_ref,8*eps); + +***** test + ## Third order filter - takes longer to settle + N=10000; + [b,a]=cheby1(3,10,0.5); + xx=ones(1,N); + [yy,zf_ref] = filter(b,a,xx); + x=xx(N:-1:N-2); + y=yy(N:-1:N-2); + zf = filtic(b,a,y,x); + assert(zf,zf_ref,8*eps); + +***** test + ## Eight order high pass filter + N=10000; + [b,a]=butter(8,0.2); + xx = cos(2*pi*linspace(0,N-1,N)/8); + [yy,zf_ref] = filter(b,a,xx); + x=xx(N:-1:N-7); + y=yy(N:-1:N-7); + zf = filtic(b,a,y,x); + assert(zf,zf_ref,8*eps); + +***** test + ## Case with 3 args + [b,a]=butter(2,0.4); + N=100; + xx=[ones(1,N) zeros(1,2)]; + [yy,zf_ref] = filter(b,a,xx); + y=[yy(N+2) yy(N+1)]; + zf=filtic(b,a,y); + assert(zf,zf_ref,8*eps); +***** test + a = [2, -3, 1]; + b = [4, -3]; + y = [0; 1]; + z = filtic (b, a, y); + assert (z, [-0.5; 0]); +7 tests, 7 passed, 0 known failure, 0 skipped +[inst/pei_tseng_notch.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/pei_tseng_notch.m +***** test + ## 2Hz bandwidth + sf = 800; sf2 = sf/2; + data=[sinetone(49,sf,10,1),sinetone(50,sf,10,1),sinetone(51,sf,10,1)]; + [b, a] = pei_tseng_notch ( 50 / sf2, 2 / sf2 ); + filtered = filter ( b, a, data ); + damp_db = 20 * log10 ( max ( filtered ( end - 1000 : end, : ) ) ); + assert ( damp_db, [ -3 -251.9 -3 ], -0.1 ) +***** test + ## 1Hz bandwidth + sf = 800; sf2 = sf/2; + data=[sinetone(49.5,sf,10,1),sinetone(50,sf,10,1),sinetone(50.5,sf,10,1)]; + [b, a] = pei_tseng_notch ( 50 / sf2, 1 / sf2 ); + filtered = filter ( b, a, data ); + damp_db = 20 * log10 ( max ( filtered ( end - 1000 : end, : ) ) ); + assert ( damp_db, [ -3 -240.4 -3 ], -0.1 ) +***** demo + sf = 800; sf2 = sf/2; + data=[[1;zeros(sf-1,1)],sinetone(49,sf,1,1),sinetone(50,sf,1,1),sinetone(51,sf,1,1)]; + [b,a]=pei_tseng_notch ( 50 / sf2, 2/sf2 ); + filtered = filter(b,a,data); + + clf + subplot ( columns ( filtered ), 1, 1) + plot(filtered(:,1),";Impulse response;") + subplot ( columns ( filtered ), 1, 2 ) + plot(filtered(:,2),";49Hz response;") + subplot ( columns ( filtered ), 1, 3 ) + plot(filtered(:,3),";50Hz response;") + subplot ( columns ( filtered ), 1, 4 ) + plot(filtered(:,4),";51Hz response;") +2 tests, 2 passed, 0 known failure, 0 skipped +[inst/welchwin.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/welchwin.m +***** demo + m = 32; + t = [0:m-1]; + printf ("Graph: single period of "); + printf ("%d-point periodic (blue) and symmetric (red) windows\n", m); + xp = welchwin (m, "periodic"); + xs = welchwin (m, "symmetric"); + plot (t, xp, "b", t, xs, "r") +***** demo + m = 32; + t = [0:4*m-1]; + printf ("Graph: 4 periods of "); + printf ("%d-point periodic (blue) and symmetric (red) windows\n", m); + xp = welchwin (m, "periodic"); + xs = welchwin (m, "symmetric"); + xp2 = repmat (xp, 4, 1); + xs2 = repmat (xs, 4, 1); + plot (t, xp2, "b", t, xs2, "r") +***** demo + m = 32; + n = 512; + xp = welchwin (m, "periodic"); + s = fftshift (max (1e-2, abs (fft (postpad (xp, n))))); + f = [-0.5:1/n:0.5-1/n]; + printf ("%dx null-padded, power spectrum of %d-point window\n", n/m, m); + semilogy (f, s) +***** assert (welchwin (3), [0; 1; 0]); +***** assert (welchwin (15), flipud (welchwin (15))); +***** assert (welchwin (16), flipud (welchwin (16))); +***** assert (welchwin (15), welchwin (15, "symmetric")); +***** assert (welchwin (16)(1:15), welchwin (15, "periodic")); +***** error welchwin () +***** error welchwin (0.5) +***** error welchwin (-1) +***** error welchwin (ones (1, 4)) +***** error welchwin (1, 2, 3) +***** error welchwin (1, "invalid") +11 tests, 11 passed, 0 known failure, 0 skipped +[inst/invimpinvar.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/invimpinvar.m +***** function err = ztoserr(bz,az,fs) + + # number of time steps + n=100; + + # make sure system is realizable (no delays) + bz=prepad(bz,length(az)-1,0,2); + + # inverse impulse invariant transform to s-domain + [bs as]=invimpinvar(bz,az,fs); + + # create sys object of transfer function + s=tf(bs,as); + + # calculate impulse response of continuous time system + # at discrete time intervals 1/fs + ys=impulse(s,(n-1)/fs,1/fs)'; + + # impulse response of discrete time system + yz=filter(bz,az,[1 zeros(1,n-1)]); + + # find rms error + err=sqrt(sum((yz*fs-ys).^2)/length(ys)); + endfunction + +***** assert(ztoserr([1],[1 -0.5],0.01),0,0.0001); +***** assert(ztoserr([1],[1 -1 0.25],0.01),0,0.0001); +***** assert(ztoserr([1 1],[1 -1 0.25],0.01),0,0.0001); +***** assert(ztoserr([1],[1 -1.5 0.75 -0.125],0.01),0,0.0001); +***** assert(ztoserr([1 1],[1 -1.5 0.75 -0.125],0.01),0,0.0001); +***** assert(ztoserr([1 1 1],[1 -1.5 0.75 -0.125],0.01),0,0.0001); +***** assert(ztoserr([1],[1 0 0.25],0.01),0,0.0001); +***** assert(ztoserr([1 1],[1 0 0.25],0.01),0,0.0001); +***** assert(ztoserr([1],[1 0 0.5 0 0.0625],0.01),0,0.0001); +***** assert(ztoserr([1 1],[1 0 0.5 0 0.0625],0.01),0,0.0001); +***** assert(ztoserr([1 1 1],[1 0 0.5 0 0.0625],0.01),0,0.0001); +***** assert(ztoserr([1 1 1 1],[1 0 0.5 0 0.0625],0.01),0,0.0001); +12 tests, 12 passed, 0 known failure, 0 skipped +[inst/downsample.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/downsample.m +***** assert(downsample([1,2,3,4,5],2),[1,3,5]); +***** assert(downsample([1;2;3;4;5],2),[1;3;5]); +***** assert(downsample([1,2;3,4;5,6;7,8;9,10],2),[1,2;5,6;9,10]); +***** assert(downsample([1,2,3,4,5],2,1),[2,4]); +***** assert(downsample([1,2;3,4;5,6;7,8;9,10],2,1),[3,4;7,8]); +5 tests, 5 passed, 0 known failure, 0 skipped +[inst/ifwht.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/ifwht.m +***** assert (isempty (ifwht ([]))); +***** assert (ifwht (zeros (16)), zeros (16)); +***** assert (ifwht ([1; (zeros (15, 1))]), ones (16, 1)); +***** assert (ifwht (zeros (17, 1)), zeros (32, 1)); +***** assert (ifwht ([0 0 0 0 0 0 0 1]), [1 -1 1 -1 1 -1 1 -1]); +***** error ifwht (); +***** error ifwht (1, 2, 3, 4); +***** error ifwht (0, 0); +***** error ifwht (0, 5); +***** error ifwht (0, [], "invalid"); +10 tests, 10 passed, 0 known failure, 0 skipped +[inst/specgram.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/specgram.m +***** shared S,f,t,x + Fs=1000; + x = chirp([0:1/Fs:2],0,2,500); # freq. sweep from 0-500 over 2 sec. + step=ceil(20*Fs/1000); # one spectral slice every 20 ms + window=ceil(100*Fs/1000); # 100 ms data window + [S, f, t] = specgram(x); + ## test of returned shape +***** assert (rows(S), 128) +***** assert (columns(f), rows(S)) +***** assert (columns(t), columns(S)) +***** test [S, f, t] = specgram(x'); +***** assert (rows(S), 128) +***** assert (columns(f), rows(S)); +***** assert (columns(t), columns(S)); +***** error (isempty(specgram([]))); +***** error (isempty(specgram([1, 2 ; 3, 4]))); +***** error (specgram) +***** demo + Fs=1000; + x = chirp([0:1/Fs:2],0,2,500); # freq. sweep from 0-500 over 2 sec. + step=ceil(20*Fs/1000); # one spectral slice every 20 ms + window=ceil(100*Fs/1000); # 100 ms data window + + ## test of automatic plot + [S, f, t] = specgram(x); + specgram(x, 2^nextpow2(window), Fs, window, window-step); +***** #demo # FIXME: Enable once we have an audio file to demo + ## Speech spectrogram + [x, Fs] = auload(file_in_loadpath("sample.wav")); # audio file + step = fix(5*Fs/1000); # one spectral slice every 5 ms + window = fix(40*Fs/1000); # 40 ms data window + fftn = 2^nextpow2(window); # next highest power of 2 + [S, f, t] = specgram(x, fftn, Fs, window, window-step); + S = abs(S(2:fftn*4000/Fs,:)); # magnitude in range 0>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cplxreal.m +***** test + [zc, zr] = cplxreal ([]); + assert (isempty (zc)) + assert (isempty (zr)) +***** test + [zc, zr] = cplxreal (1); + assert (isempty (zc)) + assert (zr, 1) +***** test + [zc, zr] = cplxreal ([1+1i, 1-1i]); + assert (zc, 1+1i) + assert (isempty (zr)) +***** test + [zc, zr] = cplxreal (roots ([1, 0, 0, 1])); + assert (zc, complex (0.5, sin (pi/3)), 10*eps) + assert (zr, -1, 2*eps) +***** test + [zc, zr] = cplxreal (roots ([1, 0, 0, 1, 0])); + assert (zc, complex (0.5, sin (pi/3)), 10*eps) + assert (zr, [-1; 0], 2*eps) +***** test + [zc, zr] = cplxreal (roots ([1, 0, 0, 1, 0, 0])); + assert (zc, complex (0.5, sin (pi/3)), 10*eps) + assert (zr, [-1; 0; 0], 2*eps) +***** error cplxreal () +***** error cplxreal (1, 2, 3, 4) +***** error cplxreal (1, ones (2, 3)) +***** error cplxreal (1, -1) +***** error cplxreal (1, [], 3) +11 tests, 11 passed, 0 known failure, 0 skipped +[inst/peak2rms.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/peak2rms.m +***** assert (peak2rms (1), 1) +***** assert (peak2rms (-5), 1) +***** assert (peak2rms ([-2 3; 4 -2]), [4/sqrt(10), 3/sqrt((9+4)/2)]) +***** assert (peak2rms ([-2 3; 4 -2], 2), [3/sqrt((9+4)/2); 4/sqrt(10)]) +***** assert (peak2rms ([1 2 3], 3), [1 1 1]) +***** error peak2rms () +***** error peak2rms (1, 2, 3) +***** error peak2rms (1, 1.5) +***** error peak2rms (1, -1) +9 tests, 9 passed, 0 known failure, 0 skipped +[inst/dst.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/dst.m +***** test + x = log(linspace(0.1,1,32)); + y = dst(x); + assert(y(3), sum(x.*sin(3*pi*[1:32]/33)), 100*eps) +1 test, 1 passed, 0 known failure, 0 skipped +[inst/isstable.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/isstable.m +***** test + b = [1 2 3 4 5 5 1 2]; + a = []; + assert (isstable (b,a), true) +***** test + b = [1 2 3 4 5 5 1 2]; + a = [4 5 6 7 9 10 4 6]; + assert (isstable (b,a), false) +***** test + b = [1 2 3 4 5 5 1 2]; + a = [4 5 6 7 9 10 4 6]; + a = polystab(a); + assert (isstable (b,a), true) +***** test + [z,p,g] = butter(6,0.7,'high'); + sos = zp2sos(z,p,g); + assert (isstable(sos) , true) +4 tests, 4 passed, 0 known failure, 0 skipped +[inst/tripuls.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/tripuls.m ***** demo fs = 11025; # arbitrary sample rate f0 = 100; # pulse train sample rate - x = pulstran (0:1/fs:4/f0, 0:1/f0:4/f0, "gauspuls"); + w = 0.5/f0; # pulse width 1/10th the distance between pulses + x = pulstran (0:1/fs:4/f0, 0:1/f0:4/f0, "tripuls", w); plot ([0:length(x)-1]*1000/fs, x); xlabel ("Time (ms)"); ylabel ("Amplitude"); - title ("Gaussian pulse train at 10 ms intervals"); -***** assert (gauspuls ([]), []) -***** assert (gauspuls (zeros (10, 1)), ones (10, 1)) -***** assert (gauspuls (-1:1), [0, 1, 0]) -***** assert (gauspuls (0:1/100:0.3, 0.1), gauspuls ([0:1/100:0.3]', 0.1)') -***** error gauspuls () -***** error gauspuls (1, 2, 3, 4) -***** error gauspuls (1, -1) -***** error gauspuls (1, 2j) -***** error gauspuls (1, 1e3, 0) -9 tests, 9 passed, 0 known failure, 0 skipped -[inst/blackmannuttall.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/blackmannuttall.m -***** assert (blackmannuttall (1), 1) -***** assert (blackmannuttall (2), 0.0003628 * ones (2, 1), eps) -***** assert (blackmannuttall (15), flipud (blackmannuttall (15)), 10*eps); -***** assert (blackmannuttall (16), flipud (blackmannuttall (16)), 10*eps); -***** assert (blackmannuttall (15), blackmannuttall (15, "symmetric")); -***** assert (blackmannuttall (16)(1:15), blackmannuttall (15, "periodic")); -***** error blackmannuttall () -***** error blackmannuttall (0.5) -***** error blackmannuttall (-1) -***** error blackmannuttall (ones (1, 4)) -***** error blackmannuttall (1, 2) -***** error blackmannuttall (1, "invalid") -12 tests, 12 passed, 0 known failure, 0 skipped -[inst/fir1.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/fir1.m -***** demo - freqz(fir1(40,0.3)); + title ("Triangular pulse train of 5 ms pulses at 10 ms intervals"); ***** demo - freqz(fir1(15,[0.2, 0.5], 'stop')); # note the zero-crossing at 0.1 + fs = 11025; # arbitrary sample rate + f0 = 100; # pulse train sample rate + w = 0.5/f0; # pulse width 1/10th the distance between pulses + x = pulstran (0:1/fs:4/f0, 0:1/f0:4/f0, "tripuls", w, -0.5); + plot ([0:length(x)-1]*1000/fs, x); + xlabel ("Time (ms)"); + ylabel ("Amplitude"); + title ("Triangular pulse train of 5 ms pulses at 10 ms intervals, skew = -0.5"); +***** assert (tripuls ([]), []) +***** assert (tripuls ([], 0.1), []) +***** assert (tripuls (zeros (10, 1)), ones (10, 1)) +***** assert (tripuls (-1:1), [0, 1, 0]) +***** assert (tripuls (-5:5, 9), [0, 1, 3, 5, 7, 9, 7, 5, 3, 1, 0] / 9) +***** assert (tripuls (0:1/100:0.3, 0.1), tripuls ([0:1/100:0.3]', 0.1)') +***** error tripuls () +***** error tripuls (1, 2, 3, 4) +***** error tripuls (1, 2j) +***** error tripuls (1, 2, 2) +***** error tripuls (1, 2, -2) +11 tests, 11 passed, 0 known failure, 0 skipped +[inst/digitrevorder.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/digitrevorder.m +***** assert (digitrevorder (0, 2), 0); +***** assert (digitrevorder (0, 36), 0); +***** assert (digitrevorder (0:3, 4), 0:3); +***** assert (digitrevorder ([0:3]', 4), [0:3]'); +***** assert (digitrevorder (0:7, 2), [0 4 2 6 1 5 3 7]); +***** assert (digitrevorder ([0:7]', 2), [0 4 2 6 1 5 3 7]'); +***** assert (digitrevorder ([0:7]*i, 2), [0 4 2 6 1 5 3 7]*i); +***** assert (digitrevorder ([0:7]'*i, 2), [0 4 2 6 1 5 3 7]'*i); +***** assert (digitrevorder (0:15, 2), [0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15]); +***** assert (digitrevorder (0:15, 4), [0 4 8 12 1 5 9 13 2 6 10 14 3 7 11 15]); +***** error digitrevorder (); +***** error digitrevorder (1); +***** error digitrevorder (1, 2, 3); +***** error digitrevorder ([], 1); +***** error digitrevorder ([], 37); +***** error digitrevorder (0:3, 8); +16 tests, 16 passed, 0 known failure, 0 skipped +[inst/bitrevorder.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/bitrevorder.m +***** assert (bitrevorder (0), 0); +***** assert (bitrevorder (0:1), 0:1); +***** assert (bitrevorder ([0:1]'), [0:1]'); +***** assert (bitrevorder (0:7), [0 4 2 6 1 5 3 7]); +***** assert (bitrevorder ([0:7]'), [0 4 2 6 1 5 3 7]'); +***** assert (bitrevorder ([0:7]*i), [0 4 2 6 1 5 3 7]*i); +***** assert (bitrevorder ([0:7]'*i), [0 4 2 6 1 5 3 7]'*i); +***** assert (bitrevorder (0:15), [0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15]); +***** error bitrevorder (); +***** error bitrevorder (1, 2); +***** error bitrevorder ([]); +***** error bitrevorder (0:2); +12 tests, 12 passed, 0 known failure, 0 skipped +[inst/pulstran.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/pulstran.m +***** error pulstran +***** error pulstran(1,2,3,4,5,6) +***** ## parameter size and shape checking +***** shared t,d + t = 0:0.01:1; d=0:0.1:1; +***** assert (isempty(pulstran([], d, 'sin'))); +***** assert (pulstran(t, [], 'sin'), zeros(size(t))); +***** assert (isempty(pulstran([], d, boxcar(5)))); +***** assert (pulstran(t, [], boxcar(5)), zeros(size(t))); +***** assert (size(pulstran(t,d,'sin')), size(t)); +***** assert (size(pulstran(t,d','sin')), size(t)); +***** assert (size(pulstran(t',d,'sin')), size(t')); +***** assert (size(pulstran(t,d','sin')), size(t)); ***** demo - freqz(fir1(15,[0.2, 0.5], 'stop', 'noscale')); -***** assert(fir1(2, .5, 'low', @hanning, 'scale'), [0 1 0]); -***** assert(fir1(2, .5, 'low', "hanning", 'scale'), [0 1 0]); -***** assert(fir1(2, .5, 'low', hanning(3), 'scale'), [0 1 0]); -***** assert(fir1(10,.5,'noscale'), fir1(10,.5,'low','hamming','noscale')); -***** assert(fir1(10,.5,'high'), fir1(10,.5,'high','hamming','scale')); -***** assert(fir1(10,.5,'boxcar'), fir1(10,.5,'low','boxcar','scale')); -***** assert(fir1(10,.5,'hanning','scale'), fir1(10,.5,'scale','hanning','low')); -***** assert(fir1(10,.5,'haNNing','NOscale'), fir1(10,.5,'noscale','Hanning','LOW')); -***** assert(fir1(10,.5,'boxcar',[]), fir1(10,.5,'boxcar')); + fs = 11025; # arbitrary sample rate + f0 = 100; # pulse train sample rate + w = 0.003; # pulse width of 3 milliseconds + t = 0:1/fs:0.1; d=0:1/f0:0.1; # define sample times and pulse times + a = hanning(length(d)); # define pulse amplitudes + + subplot(221); + x = pulstran(t', d', 'rectpuls', w); + plot([0:length(x)-1]*1000/fs, x); + hold on; plot(d*1000,ones(size(d)),'g*;pulse;'); hold off; + ylabel("amplitude"); xlabel("time (ms)"); + title("rectpuls"); + + subplot(223); + x = pulstran(f0*t, [f0*d', a], 'sinc'); + plot([0:length(x)-1]*1000/fs, x); + hold on; plot(d*1000,a,'g*;pulse;'); hold off; + ylabel("amplitude"); xlabel("time (ms)"); + title("sinc => band limited interpolation"); + + subplot(222); + pulse = boxcar(30); # pulse width of 3 ms at 10 kHz + x = pulstran(t, d', pulse, 10000); + plot([0:length(x)-1]*1000/fs, x); + hold on; plot(d*1000,ones(size(d)),'g*;pulse;'); hold off; + ylabel("amplitude"); xlabel("time (ms)"); + title("interpolated boxcar"); + + subplot(224); + pulse = sin(2*pi*[0:0.0001:w]/w).*[w:-0.0001:0]; + x = pulstran(t', [d', a], pulse', 10000); + plot([0:length(x)-1]*1000/fs, x); + hold on; plot(d*1000,a*w,'g*;pulse;'); hold off; title(""); + ylabel("amplitude"); xlabel("time (ms)"); + title("interpolated asymmetric sin"); + + %---------------------------------------------------------- + % Should see (1) rectangular pulses centered on *, + % (2) rectangular pulses to the right of *, + % (3) smooth interpolation between the *'s, and + % (4) asymmetric sines to the right of * +10 tests, 10 passed, 0 known failure, 0 skipped +[inst/uencode.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/uencode.m +***** test + u = [-3:0.5:3]; + y = uencode (u, 2); + assert (y, [0 0 0 0 0 1 2 3 3 3 3 3 3]); +***** test + u = [-4:0.5:4]; + y = uencode (u, 3, 4); + assert (y, [0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 7]); +***** test + u = [-8:0.5:8]; + y = uencode(u, 4, 8, "unsigned"); + assert (y, [0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 15]); +***** test + u = [-8:0.5:8]; + y = uencode(u, 4, 8, "signed"); + assert (y, [-8 -8 -7 -7 -6 -6 -5 -5 -4 -4 -3 -3 -2 -2 -1 -1 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 7]); +***** error uencode () +***** error uencode (1) +***** error uencode (1, 2, 3, 4, 5) +***** error uencode (1, 100) +***** error uencode (1, 4, 0) +***** error uencode (1, 4, -1) +***** error uencode (1, 4, 2, "invalid") +11 tests, 11 passed, 0 known failure, 0 skipped +[inst/boxcar.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/boxcar.m +***** assert (boxcar (1), 1) +***** assert (boxcar (2), ones (2, 1)) +***** assert (boxcar (100), ones (100, 1)) +***** error boxcar () +***** error boxcar (0.5) +***** error boxcar (-1) +***** error boxcar (ones (1, 4)) +***** error boxcar (1, 2) +8 tests, 8 passed, 0 known failure, 0 skipped +[inst/fht.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/fht.m +***** assert( fht([1 2 3 4]),[10 -4 -2 0] ) + +1 test, 1 passed, 0 known failure, 0 skipped +[inst/fwhm.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/fwhm.m ***** test - b = fir1 (30, 0.3); - h = abs (freqz (b, 1, [0, 0.3, 1], 2)); - assert (h(1), 1, 1e-3) - assert (all (h(2:3) <= [1/sqrt(2), 3e-3])) + x=-pi:0.001:pi; y=cos(x); + assert( abs(fwhm(x, y) - 2*pi/3) < 0.01 ); + ***** test - b = fir1 (30, 0.7, "high"); - h = abs (freqz (b, 1, [0, 0.7, 1], 2)); - assert (h(3), 1, 1e-3) - assert (all (h(1:2) <= [3e-3, 1/sqrt(2)])) + assert( fwhm(-10:10) == 0 && fwhm(ones(1,50)) == 0 ); + ***** test - b = fir1 (30, [0.3, 0.7]); - h = abs (freqz (b, 1, [0, 0.3, 0.5, 0.7, 1], 2)); - assert (h(3), 1, 1e-3) - assert (all (h([1:2, 4:5]) <= [3e-3, 1/sqrt(2), 1/sqrt(2), 3e-3])) + x=-20:1:20; + y1=-4+zeros(size(x)); y1(4:10)=8; + y2=-2+zeros(size(x)); y2(4:11)=2; + y3= 2+zeros(size(x)); y3(5:13)=10; + assert( max(abs(fwhm(x, [y1;y2;y3]') - [20.0/3,7.5,9.25])) < 0.01 ); + ***** test - b = fir1 (50, [0.3, 0.7], "stop"); - h = abs (freqz (b, 1, [0, 0.3, 0.5, 0.7, 1], 2)); - assert (h(1), 1, 1e-3) - assert (h(5), 1, 1e-3) - assert (all (h(2:4) <= [1/sqrt(2), 3e-3, 1/sqrt(2)])) -13 tests, 13 passed, 0 known failure, 0 skipped -[inst/xcorr2.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/xcorr2.m -***** test # basic usage - a = magic (5); - b = [6 13 22; 10 18 23; 8 15 23]; - c = [391 807 519 391 473 289 120 - 920 1318 1045 909 1133 702 278 - 995 1476 1338 1534 2040 1161 426 - 828 1045 1501 2047 2108 1101 340 - 571 1219 2074 2155 1896 821 234 - 473 1006 1643 1457 946 347 108 - 242 539 850 477 374 129 54]; - assert (xcorr2 (a, b), c); -***** shared a, b, c, row_shift, col_shift - row_shift = 18; - col_shift = 20; - a = randi (255, 30, 30); - b = a(row_shift-10:row_shift, col_shift-7:col_shift); - c = xcorr2 (a, b, "coeff"); -***** assert (nthargout ([1 2], @find, c == max (c(:))), {row_shift, col_shift}); # should return exact coordinates - m = rand (size (b)) > 0.5; - b(m) = b(m) * 0.95; - b(!m) = b(!m) * 1.05; - c = xcorr2 (a, b, "coeff"); -***** assert (nthargout ([1 2], @find, c == max (c(:))), {row_shift, col_shift}); # even with some small noise, should return exact coordinates -***** test # coeff of autocorrelation must be same as negative of correlation by additive inverse - a = 10 * randn (100, 100); - auto = xcorr2 (a, "coeff"); - add_in = xcorr2 (a, -a, "coeff"); - assert ([min(auto(:)), max(auto(:))], -[max(add_in(:)), min(add_in(:))]); -4 tests, 4 passed, 0 known failure, 0 skipped + x=1:3; y=[-1,3,-1]; assert(abs(fwhm(x,y)-0.75)<0.001 && abs(fwhm(x,y,'zero')-0.75)<0.001 && abs(fwhm(x,y,'min')-1.0)<0.001); + +***** test + x=1:3; y=[-1,3,-1]; assert(abs(fwhm(x,y, 'rlevel', 0.1)-1.35)<0.001 && abs(fwhm(x,y,'zero', 'rlevel', 0.1)-1.35)<0.001 && abs(fwhm(x,y,'min', 'rlevel', 0.1)-1.40)<0.001); + +***** test + x=1:3; y=[-1,3,-1]; assert(abs(fwhm(x,y, 'alevel', 2.5)-0.25)<0.001 && abs(fwhm(x,y,'alevel', -0.5)-1.75)<0.001); + +***** test + x=-10:10; assert( fwhm(x.*x) == 0 ); + +***** test + x=-5:5; y=18-x.*x; assert( abs(fwhm(y)-6.0) < 0.001 && abs(fwhm(x,y,'zero')-6.0) < 0.001 && abs(fwhm(x,y,'min')-7.0 ) < 0.001); +8 tests, 8 passed, 0 known failure, 0 skipped [inst/filternorm.m] >>>>> /build/reproducible-path/octave-signal-1.4.5/inst/filternorm.m ***** demo @@ -6448,475 +8064,423 @@ Linf = filternorm (b, a, Inf); assert (Linf, 1, 1e-8); 12 tests, 12 passed, 0 known failure, 0 skipped -[inst/besself.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/besself.m -***** error [a, b] = besself () -***** error [a, b] = besself (1) -***** error [a, b] = besself (1, 2, 3, 4, 5) -***** error [a, b] = besself (.5, .2) -***** error [a, b] = besself (3, .2, "invalid") -5 tests, 5 passed, 0 known failure, 0 skipped -[inst/parzenwin.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/parzenwin.m -***** assert (parzenwin (1), 1) -***** assert (parzenwin (2), 0.25 * ones (2, 1)) -***** error parzenwin () -***** error parzenwin (0.5) -***** error parzenwin (-1) -***** error parzenwin (ones (1, 4)) -***** error parzenwin (1, 2) +[inst/zp2sos.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/zp2sos.m +***** test + B=[1 0 0 0 0 1]; A=[1 0 0 0 0 .9]; + [z,p,k] = tf2zp(B,A); + [sos,g] = zp2sos(z,p,k); + [Bh,Ah] = sos2tf(sos,g); + assert({Bh,Ah},{B,A},100*eps); +***** test + sos = zp2sos ([]); + assert (sos, [1, 0, 0, 1, 0, 0], 100*eps); +***** test + sos = zp2sos ([], []); + assert (sos, [1, 0, 0, 1, 0, 0], 100*eps); +***** test + sos = zp2sos ([], [], 2); + assert (sos, [2, 0, 0, 1, 0, 0], 100*eps); +***** test + [sos, g] = zp2sos ([], [], 2); + assert (sos, [1, 0, 0, 1, 0, 0], 100*eps); + assert (g, 2, 100*eps); +***** test + sos = zp2sos([], [0], 1); + assert (sos, [0, 1, 0, 1, 0, 0], 100*eps); +***** test + sos = zp2sos([0], [], 1); + assert (sos, [1, 0, 0, 0, 1, 0], 100*eps); +***** test + sos = zp2sos([-1-j -1+j], [-1-2j -1+2j], 10); + assert (sos, [10, 20, 20, 1, 2, 5], 100*eps); +8 tests, 8 passed, 0 known failure, 0 skipped +[inst/sos2zp.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/sos2zp.m +***** test + b1t=[1 2 3]; a1t=[1 .2 .3]; + b2t=[4 5 6]; a2t=[1 .4 .5]; + sos=[b1t a1t; b2t a2t]; + z = [-1-1.41421356237310i;-1+1.41421356237310i;... + -0.625-1.05326872164704i;-0.625+1.05326872164704i]; + p = [-0.2-0.678232998312527i;-0.2+0.678232998312527i;... + -0.1-0.538516480713450i;-0.1+0.538516480713450i]; + k = 4; + [z2,p2,k2] = sos2zp(sos,1); + assert({cplxpair(z2),cplxpair(p2),k2},{z,p,k},100*eps); +***** test + sos = [1, 1, 0, 1, 1, 0.5]; + [Z, P] = sos2zp (sos); + assert (Z, roots (sos(1,1:3)), 10*eps); + assert (P, roots (sos(1,4:6)), 10*eps); +***** test + sos = [0, 1, 1, 1, 0.5, 0]; + [Z, P] = sos2zp (sos); + assert (Z, roots (sos(1,1:3)), 10*eps); + assert (P, roots (sos(1,4:6)), 10*eps); +***** test + sos = [1, 1, 0, 1, 0.5, 0]; + [Z, P] = sos2zp (sos); + assert (Z, roots (sos(1,1:3)), 10*eps); + assert (P, roots (sos(1,4:6)), 10*eps); +***** test + sos = [0, 1, 1, 1, 1, 0.5]; + [Z, P] = sos2zp (sos); + assert (Z, roots (sos(1,1:3)), 10*eps); + assert (P, roots (sos(1,4:6)), 10*eps); +***** test + sos = [1, 1, 0, 0, 1, 0.5]; + [Z, P] = sos2zp (sos); + assert (Z, roots (sos(1,1:3)), 10*eps); + assert (P, roots (sos(1,4:6)), 10*eps); +***** test + sos = [0, 1, 1, 0, 1, 0.5]; + [Z, P] = sos2zp (sos); + assert (Z, roots (sos(1,1:3)), 10*eps); + assert (P, roots (sos(1,4:6)), 10*eps); 7 tests, 7 passed, 0 known failure, 0 skipped -[inst/welchwin.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/welchwin.m -***** demo - m = 32; - t = [0:m-1]; - printf ("Graph: single period of "); - printf ("%d-point periodic (blue) and symmetric (red) windows\n", m); - xp = welchwin (m, "periodic"); - xs = welchwin (m, "symmetric"); - plot (t, xp, "b", t, xs, "r") +[inst/decimate.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/decimate.m ***** demo - m = 32; - t = [0:4*m-1]; - printf ("Graph: 4 periods of "); - printf ("%d-point periodic (blue) and symmetric (red) windows\n", m); - xp = welchwin (m, "periodic"); - xs = welchwin (m, "symmetric"); - xp2 = repmat (xp, 4, 1); - xs2 = repmat (xs, 4, 1); - plot (t, xp2, "b", t, xs2, "r") + t=0:0.01:2; x=chirp(t,2,.5,10,'quadratic')+sin(2*pi*t*0.4); + y = decimate(x,4); # factor of 4 decimation + stem(t(1:121)*1000,x(1:121),"-g;Original;"); hold on; # plot original + stem(t(1:4:121)*1000,y(1:31),"-r;Decimated;"); hold off; # decimated + %------------------------------------------------------------------ + % The signal to decimate starts away from zero, is slowly varying + % at the start and quickly varying at the end, decimate and plot. + % Since it starts away from zero, you will see the boundary + % effects of the antialiasing filter clearly. You will also see + % how it follows the curve nicely in the slowly varying early + % part of the signal, but averages the curve in the quickly + % varying late part of the signal. +***** error decimate () +***** error decimate (1) +***** error decimate (1, 2, 3, 4, 5) +***** error decimate (1, -1) +4 tests, 4 passed, 0 known failure, 0 skipped +[inst/flattopwin.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/flattopwin.m +***** assert (flattopwin (1), 1); +***** assert (flattopwin (2), 0.0042 / 4.6402 * ones (2, 1), eps); +***** assert (flattopwin (15), flipud (flattopwin (15)), 10*eps); +***** assert (flattopwin (16), flipud (flattopwin (16)), 10*eps); +***** assert (flattopwin (15), flattopwin (15, "symmetric")); +***** assert (flattopwin (16)(1:15), flattopwin (15, "periodic")); +***** error flattopwin () +***** error flattopwin (0.5) +***** error flattopwin (-1) +***** error flattopwin (ones (1, 4)) +***** error flattopwin (1, 2) +***** error flattopwin (1, 2, 3) +***** error flattopwin (1, "invalid") +13 tests, 13 passed, 0 known failure, 0 skipped +[inst/ellip.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/ellip.m ***** demo - m = 32; - n = 512; - xp = welchwin (m, "periodic"); - s = fftshift (max (1e-2, abs (fft (postpad (xp, n))))); - f = [-0.5:1/n:0.5-1/n]; - printf ("%dx null-padded, power spectrum of %d-point window\n", n/m, m); - semilogy (f, s) -***** assert (welchwin (3), [0; 1; 0]); -***** assert (welchwin (15), flipud (welchwin (15))); -***** assert (welchwin (16), flipud (welchwin (16))); -***** assert (welchwin (15), welchwin (15, "symmetric")); -***** assert (welchwin (16)(1:15), welchwin (15, "periodic")); -***** error welchwin () -***** error welchwin (0.5) -***** error welchwin (-1) -***** error welchwin (ones (1, 4)) -***** error welchwin (1, 2, 3) -***** error welchwin (1, "invalid") -11 tests, 11 passed, 0 known failure, 0 skipped -[inst/invimpinvar.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/invimpinvar.m -***** function err = ztoserr(bz,az,fs) - - # number of time steps - n=100; - - # make sure system is realizable (no delays) - bz=prepad(bz,length(az)-1,0,2); - - # inverse impulse invariant transform to s-domain - [bs as]=invimpinvar(bz,az,fs); - - # create sys object of transfer function - s=tf(bs,as); - - # calculate impulse response of continuous time system - # at discrete time intervals 1/fs - ys=impulse(s,(n-1)/fs,1/fs)'; - - # impulse response of discrete time system - yz=filter(bz,az,[1 zeros(1,n-1)]); + [n, Ws] = ellipord ([.1 .2], [.01 .4], 1, 90); + [b, a] = ellip (5, 1, 90, [.1 .2]); + [h, w] = freqz (b, a); - # find rms error - err=sqrt(sum((yz*fs-ys).^2)/length(ys)); - endfunction + plot (w./pi, 20*log10 (abs (h)), ";;") + xlabel ("Frequency"); + ylabel ("abs(H[w])[dB]"); + axis ([0, 1, -100, 0]); -***** assert(ztoserr([1],[1 -0.5],0.01),0,0.0001); -***** assert(ztoserr([1],[1 -1 0.25],0.01),0,0.0001); -***** assert(ztoserr([1 1],[1 -1 0.25],0.01),0,0.0001); -***** assert(ztoserr([1],[1 -1.5 0.75 -0.125],0.01),0,0.0001); -***** assert(ztoserr([1 1],[1 -1.5 0.75 -0.125],0.01),0,0.0001); -***** assert(ztoserr([1 1 1],[1 -1.5 0.75 -0.125],0.01),0,0.0001); -***** assert(ztoserr([1],[1 0 0.25],0.01),0,0.0001); -***** assert(ztoserr([1 1],[1 0 0.25],0.01),0,0.0001); -***** assert(ztoserr([1],[1 0 0.5 0 0.0625],0.01),0,0.0001); -***** assert(ztoserr([1 1],[1 0 0.5 0 0.0625],0.01),0,0.0001); -***** assert(ztoserr([1 1 1],[1 0 0.5 0 0.0625],0.01),0,0.0001); -***** assert(ztoserr([1 1 1 1],[1 0 0.5 0 0.0625],0.01),0,0.0001); + hold ("on"); + x=ones (1, length (h)); + plot (w./pi, x.*-1, ";-1 dB;") + plot (w./pi, x.*-90, ";-90 dB;") + hold ("off"); +***** error [a, b] = ellip () +***** error [a, b] = ellip (1) +***** error [a, b] = ellip (1, 2) +***** error [a, b] = ellip (1, 2, 3) +***** error [a, b] = ellip (1, 2, 3, 4, 5, 6, 7) +***** error [a, b] = ellip (.5, 2, 40, .2) +***** error [a, b] = ellip (3, 2, 40, .2, "invalid") +***** test + ellip (6, 3, 50, .6); + assert (isrow (ans)); +***** test + A = ellip (6, 3, 50, .6); + assert (isrow (A)); +***** test + [A, B] = ellip (6, 3, 50, .6); + assert (isrow (A)); + assert (isrow (B)); +***** test + [z, p, g] = ellip (6, 3, 50, .6); + assert (iscolumn (z)); + assert (iscolumn (p)); + assert (isscalar (g)); +***** test + [a, b, c, d] = ellip (6, 3, 50, .6); + assert (ismatrix (a)); + assert (iscolumn (b)); + assert (isrow (c)); + assert (isscalar (d)); 12 tests, 12 passed, 0 known failure, 0 skipped -[inst/fht.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/fht.m -***** assert( fht([1 2 3 4]),[10 -4 -2 0] ) - -1 test, 1 passed, 0 known failure, 0 skipped -[inst/pow2db.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/pow2db.m -***** shared pow - pow = [0, 10, 20, 60, 100]; -***** assert (pow2db (pow), [-Inf, 10.000, 13.010, 17.782, 20.000], 0.01) -***** assert (pow2db (pow'), [-Inf; 10.000; 13.010; 17.782; 20.000], 0.01) -***** error pow2db () -***** error pow2db (1, 2) -***** error pow2db (-5) -***** error pow2db ([-5 7]) -6 tests, 6 passed, 0 known failure, 0 skipped -[inst/convmtx.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/convmtx.m -***** assert(convmtx([3,4,5],3),[3,4,5,0,0;0,3,4,5,0;0,0,3,4,5]) -***** assert(convmtx([3;4;5],3),[3,0,0;4,3,0;5,4,3;0,5,4;0,0,5]) -2 tests, 2 passed, 0 known failure, 0 skipped -[inst/ifwht.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/ifwht.m -***** assert (isempty (ifwht ([]))); -***** assert (ifwht (zeros (16)), zeros (16)); -***** assert (ifwht ([1; (zeros (15, 1))]), ones (16, 1)); -***** assert (ifwht (zeros (17, 1)), zeros (32, 1)); -***** assert (ifwht ([0 0 0 0 0 0 0 1]), [1 -1 1 -1 1 -1 1 -1]); -***** error ifwht (); -***** error ifwht (1, 2, 3, 4); -***** error ifwht (0, 0); -***** error ifwht (0, 5); -***** error ifwht (0, [], "invalid"); -10 tests, 10 passed, 0 known failure, 0 skipped -[inst/gausswin.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/gausswin.m -***** assert (gausswin (1), 1) -***** assert (gausswin (2), [exp(-3.125); exp(-3.125)]) -***** assert (gausswin (3), [exp(-3.125); 1; exp(-3.125)]) -***** error gausswin () -***** error gausswin (0.5) -***** error gausswin (-1) -***** error gausswin (ones (1, 4)) -***** error gausswin (1, 2, 3) -8 tests, 8 passed, 0 known failure, 0 skipped -[inst/chebwin.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/chebwin.m -***** assert (chebwin (1), 1) -***** assert (chebwin (2), ones (2, 1)) -***** error chebwin () -***** error chebwin (0.5) -***** error chebwin (-1) -***** error chebwin (ones (1, 4)) -***** error chebwin (1, 2, 3) -7 tests, 7 passed, 0 known failure, 0 skipped -[inst/chirp.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/chirp.m -***** demo - t = 0:0.001:5; - y = chirp (t); - specgram (y, 256, 1000); - %------------------------------------------------------------ - % Shows linear sweep of 100 Hz/sec starting at zero for 5 sec - % since the sample rate is 1000 Hz, this should be a diagonal - % from bottom left to top right. -***** demo - t = -2:0.001:15; - y = chirp (t, 400, 10, 100, "quadratic"); - [S, f, t] = specgram (y, 256, 1000); - t = t - 2; - imagesc(t, f, 20 * log10 (abs (S))); - set (gca (), "ydir", "normal"); - xlabel ("Time"); - ylabel ("Frequency"); - %------------------------------------------------------------ - % Shows a quadratic chirp of 400 Hz at t=0 and 100 Hz at t=10 - % Time goes from -2 to 15 seconds. -***** demo - t = 0:1/8000:5; - y = chirp (t, 200, 2, 500, "logarithmic"); - specgram (y, 256, 8000); - %------------------------------------------------------------- - % Shows a logarithmic chirp of 200 Hz at t=0 and 500 Hz at t=2 - % Time goes from 0 to 5 seconds at 8000 Hz. -***** shared t - t = (0:5000) ./ 1000; +[inst/udecode.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/udecode.m ***** test - y1 = chirp (t); - y2 = chirp (t, 0, 1, 100, "linear", 0); - assert (y2, y1) + u = [0 0 0 0 0 1 2 3 3 3 3 3 3]; + y = udecode(u, 2); + assert(y, [-1 -1 -1 -1 -1 -0.5 0 0.5 0.5 0.5 0.5 0.5 0.5]); ***** test - y1 = chirp (t, [], [], [], "li"); - y2 = chirp (t, 0, 1, 100, "linear", 0); - assert (y2, y1) + u = [0 1 2 3 4 5 6 7 8 9 10]; + y = udecode(u, 2, 1, "saturate"); + assert(y, [-1 -0.5 0 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5]); ***** test - y1 = chirp (t, [], [], [], "q"); - y2 = chirp (t, 0, 1, 100, "quadratic", 0); - assert (y2, y1) + u = [0 1 2 3 4 5 6 7 8 9 10]; + y = udecode(u, 2, 1, "wrap"); + assert(y, [-1 -0.5 0 0.5 -1 -0.5 0 0.5 -1 -0.5 0]); ***** test - y1 = chirp (t, [], [], [], "lo"); - y2 = chirp (t, 1e-6, 1, 100, "logarithmic", 0); - assert (y2, y1) -***** error chirp () -***** error chirp (1, 2, 3, 4, 5, 6, 7) -***** error chirp (0, [], [], [], "l") -***** error chirp (0, [], [], [], "foo") -8 tests, 8 passed, 0 known failure, 0 skipped -[inst/sgolay.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/sgolay.m + u = [-4 -3 -2 -1 0 1 2 3]; + y = udecode(u, 3, 2); + assert(y, [-2, -1.5 -1 -0.5 0 0.5 1 1.5]); ***** test - N=2^12; - t=[0:N-1]'/N; - dt=t(2)-t(1); - w = 2*pi*50; - offset = 0.5; # 50 Hz carrier - # exponential modulation and its derivatives - d = 1+exp(-3*(t-offset)); - dd = -3*exp(-3*(t-offset)); - d2d = 9*exp(-3*(t-offset)); - d3d = -27*exp(-3*(t-offset)); - # modulated carrier and its derivatives - x = d.*sin(w*t); - dx = dd.*sin(w*t) + w*d.*cos(w*t); - d2x = (d2d-w^2*d).*sin(w*t) + 2*w*dd.*cos(w*t); - d3x = (d3d-3*w^2*dd).*sin(w*t) + (3*w*d2d-w^3*d).*cos(w*t); - - y = sgolayfilt(x,sgolay(8,41,0,dt)); - assert(norm(y-x)/norm(x),0,5e-6); - - y = sgolayfilt(x,sgolay(8,41,1,dt)); - assert(norm(y-dx)/norm(dx),0,5e-6); - - y = sgolayfilt(x,sgolay(8,41,2,dt)); - assert(norm(y-d2x)/norm(d2x),0,1e-5); - - y = sgolayfilt(x,sgolay(8,41,3,dt)); - assert(norm(y-d3x)/norm(d3x),0,1e-4); -1 test, 1 passed, 0 known failure, 0 skipped -[inst/firpmord.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/firpmord.m -***** error firpmord ([1 2], [1 0], [1 1], [1 1]); -***** error firpmord ([0 2], [1 0], [1 1]); -***** error firpmord ([.1 1], [1 0], [1 1]); -***** error firpmord ([.1 .9], [1], [.1 .1]); -***** error firpmord ([.1 .2], [1 0], [.1 .1 .1]); -***** error firpmord ([.1 .2], [1 0], [1 0]); -***** assert ( - firpmord ([0.4 0.5], [0 1], [2.5e-4 2.5e-4]), - firpmord ([0.4 0.5], [0 1], [2.5e-4])) -***** test ds = 1e-4; dp = 0.01; assert ( - firpmord ([1 2 3 4 5 6 7 8]/10, [0 1 0 1 0], [ds dp ds dp ds]), - firpmord ([1 2 3 4 5 6 7 8]/10, [0 1 0 1 0], [ds dp])) -***** assert (1 + firpmord ([.1 .2], [0 1], [1e-4 .01], 1), 33) -***** assert (1 + firpmord ([ 15 20], [ 1 0], [ .1 .001], 100), 38) -***** assert (1 + firpmord ([ 8 10 ], [0 1 ], [.001 .1 ], 100), 91) -***** assert (1 + firpmord ([ 8 10 15 20], [0 1 0], [.001 .1 .001], 100), 90) #+1? -***** assert (1 + firpmord ([17 20 ], [1 0 ], [.01 1e-4 ], 100), 107)#-1? -***** assert (1 + firpmord ([ 22 25], [ 0 1], [ 1e-4 .01], 100), 107) -***** assert (1 + firpmord ([17 20 22 25], [1 0 1], [.01 1e-4 .01], 100), 107) -***** assert (1 + firpmord ([ 21 25], [ 1 0], [ .01 1e-4], 100), 81) #+1? -***** assert (1 + firpmord ([10 20 ], [0 1 ], [1e-4 .01 ], 100), 33) -***** assert (1 + firpmord ([10 20 21 25], [0 1 0], [1e-4 .01 1e-4], 100), 81) #+1? -***** assert (1 + firpmord ([20 25 ], [1 0 ], [.01 1e-4 ], 100), 65) #+1? -***** assert (1 + firpmord ([ 26 30], [ 0 1], [ 1e-4 .01], 100), 81) #+2? -***** assert (1 + firpmord ([20 25 26 30], [1 0 1], [.01 1e-4 .01], 100), 81) #+2? - -***** demo - - db2mag = @(x) 10^(x/20); - - fs = 8000; - [n f a w] = firpmord ([2500 3000], [1 0], [0.01 db2mag(-60)], fs); - b = firpm (n, f, a, w); - - [h f] = freqz (b, 1, 2^14); clf - plot (fs/2*f/pi, 20*log10 (abs (h))); grid on; axis ([0 fs/2 -90 5]) - ylabel ("Magnitude (dB)"); xlabel ("Frequency (Hz)") - title (sprintf ("Response analysis of firpmord / firpm low-pass filter design (order=%i)", length (b) - 1)) - axes ("position", [.24 .4 .4 .3]) - plot (fs/2*f/pi, abs (h)); grid on; axis ([0 2600 x=.987 2-x]) - ylabel ("Magnitude") - title ("Pass-band detail") - %-------------------------------------------------- - % Figure shows analysis of filter designed using - % firpm with firpmord; specs. are almost met. - -***** demo - - db2mag = @(x) 10^(x/20); - - b = firpm (firpmord ([0.3 0.4], [0 1], [db2mag(-80) .01], "c"){:}); - - [h f] = freqz (b, 1, 2^14); clf - plot (f/pi, 20*log10 (abs (h))); grid on; axis ([0 1 -110 5]) - ylabel ("Magnitude (dB)"); xlabel ("Frequency (normalized)") - title (sprintf ("Response analysis of firpmord / firpm high-pass filter design (order=%i)", length (b) - 1)) - axes ("position", [.52 .4 .35 .3]) - plot (f/pi, abs (h)); grid on; axis ([.39 1 x=.987 2-x]) - ylabel ("Magnitude") - title ("Pass-band detail") - %-------------------------------------------------- - % Figure shows analysis of filter designed using - % firpm with firpmord; specs. are exceeded. - -***** demo - - db2mag = @(x) 10^(x/20); - - ds = db2mag (-80); dp = 0.01; - b = firpm (firpmord ([1 2 3 4 5 6 7 8]/10, [0 1 0 1 0], [ds dp], "c"){:}); - - [h f] = freqz (b, 1, 2^14); clf - plot (f/pi, 20*log10 (abs (h))); grid on; axis ([0 1 -110 5]) - ylabel ("Magnitude (dB)"); xlabel ("Frequency (normalized)") - title ("Response analysis of firpmord / firpm multi-band-pass filter design") - title (sprintf ("Response analysis of firpmord / firpm multi-band-pass filter design (order=%i)", length (b) - 1)) - axes ("position", [.38 .5 .5 .2]) - plot (f/pi, abs (h)); grid on; axis ([.11 .79 x=.986 2-x]) - ylabel ("Magnitude") - title ("Pass-bands detail") - %-------------------------------------------------- - % Figure shows analysis of filter designed using - % firpm with firpmord; specs. are met. - -***** demo - - db2mag = @(x) 10^(x/20); - - ds = db2mag (-40); dp = 1 - db2mag (-0.1); - b = firpm (firpmord ([2 3 8 9]/32, [0 1 0], [ds dp], "c"){:}); - - [h f] = freqz (b, 1, 2^14); clf - plot (f/pi, 20*log10 (abs (h))); grid on; axis ([0 1 -50 3]) - ylabel ("Magnitude (dB)"); xlabel ("Frequency (normalized)") - title (sprintf ("Response analysis of firpmord / firpm band-pass filter design (order=%i)", length (b) - 1)) - axes ("position", [.45 .5 .4 .3]) - plot (f/pi, 20*log10 (abs (h))); grid on; axis ([.08 .26 x=-.13 -x]) - ylabel ("Magnitude (dB)") - title ("Pass-band detail") - %-------------------------------------------------- - % Figure shows analysis of filter designed using - % firpm with firpmord; specs. are not met. - -***** demo - - % FIRPMX: F, A, D, Fs are as firpmord. - % type in {0,1,2} constrains order to be {even,odd,either} resp. - - function h = firpmx (type, F, A, D, Fs = 2) - type *= !A(end); step = 2; bounds = [0 0]; - while (bounds(2) - bounds(1) != step) - if all (!bounds) [n f a w] = firpmord (F, A, D, Fs); - elseif (!bounds(1)) n = min (n - step, round (n * 0.994)); - elseif (!bounds(2)) n = max (n + step, round (n / 0.998)); - else n = fix (mean (bounds)); - endif - n += rem (n + rem (type, 2), step); - [b m] = firpm (n, f, a, w); - bounds(1 + (met = (abs(m) <= max (D)))) = n; - step -= bounds(2) - bounds(1) == type; - if (met) h = b; endif - endwhile - endfunction - - db2mag = @(x) 10^(x/20); - - ds = db2mag (-40); dp = 1 - db2mag (-0.1); - b = firpmx (2, [2 3 8 9]/32, [0 1 0], [ds dp]); + u = [-7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7]; + y = udecode(u, 3, 2, "saturate"); + assert(y, [-2 -2 -2 -2 -1.5 -1 -0.5 0 0.5 1 1.5 1.5 1.5 1.5 1.5]); +***** test + u = [-7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7]; + y = udecode(u, 3, 2, "wrap"); + assert(y, [0.5 1 1.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 -2 -1.5 -1 -0.5]); +***** error udecode () +***** error udecode (1) +***** error udecode (1, 2, 3, 4, 5) +***** error udecode (1.5) +***** error udecode (1, 100) +***** error udecode (1, 4, 0) +***** error udecode (1, 4, -1) +***** error udecode (1, 4, 2, "invalid") +14 tests, 14 passed, 0 known failure, 0 skipped +[inst/xcov.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/xcov.m +***** error xcov () +***** test + x = 1:5; + [c, l] = xcov(x); + assert(c, [-4.0 -4.0 -1.0 4.0 10.0 4.0 -1.0 -4.0 -4.0], 2*eps) + assert(l, [-4 -3 -2 -1 0 1 2 3 4]) +***** test + x = 1:5; + y = 1:5; + [c, l] = xcov(x,y); + assert(c, [-4.0 -4.0 -1.0 4.0 10.0 4.0 -1.0 -4.0 -4.0], 2*eps) + assert(l, [-4 -3 -2 -1 0 1 2 3 4]) - [h f] = freqz (b, 1, 2^14); clf - plot (f/pi, 20*log10 (abs (h))); grid on; axis ([0 1 -50 3]) - ylabel ("Magnitude (dB)"); xlabel ("Frequency (normalized)") - title (sprintf ("Response analysis of firpmord / iterative-firpm band-pass filter design (order=%i)", length (b) - 1)) - axes ("position", [.45 .5 .4 .3]) - plot (f/pi, 20*log10 (abs (h))); grid on; axis ([.08 .26 x=-.13 -x]) - ylabel ("Magnitude (dB)") - title ("Pass-band detail") - %-------------------------------------------------- - % Figure shows analysis of filter designed iteratively - % using firpm with firpmord, so that specs. are met. -21 tests, 21 passed, 0 known failure, 0 skipped -[inst/tf2sos.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/tf2sos.m + y = 1; + [c, l] = xcov(x,y); + assert(c, [4.0 10.0 4.0], 2*eps) + assert(l, [-1 0 1]) ***** test - B=[1 0 0 0 0 1]; A=[1 0 0 0 0 .9]; - [sos,g] = tf2sos(B,A); - [Bh,Ah] = sos2tf(sos,g); - assert({Bh,Ah},{B,A},100*eps); -1 test, 1 passed, 0 known failure, 0 skipped -[inst/shiftdata.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/shiftdata.m + x = 1:5; + y = 1:5; + # maxlag + [c, l] = xcov(x,y, 2); + assert(c, [-1.0 4.0 10.0 4.0 -1.0], 2*eps) + assert(l, [-2 -1 0 1 2]) ***** test - X = [1 2 3; 4 5 6; 7 8 9]; - [Y, perm, shifts] = shiftdata (X, 2); - assert (Y, [1 4 7; 2 5 8; 3 6 9]); - assert (perm, [2 1]); + x = 1:5; + y = 1:5; + # scale + [c, l] = xcov(x,y, 'none'); + assert(c, [-4.0 -4.0 -1.0 4.0 10.0 4.0 -1.0 -4.0 -4.0], 2*eps) + assert(l, [-4 -3 -2 -1 0 1 2 3 4]) + + [c, l] = xcov(x,y, 'biased'); + assert(c, [-0.8 -0.8 -0.2 0.8 2.0 0.8 -0.2 -0.8 -0.8], 2*eps) + assert(l, [-4 -3 -2 -1 0 1 2 3 4]) +5 tests, 5 passed, 0 known failure, 0 skipped +[inst/cheby2.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cheby2.m +***** error [a, b] = cheby2 () +***** error [a, b] = cheby2 (1) +***** error [a, b] = cheby2 (1, 2) +***** error [a, b] = cheby2 (1, 2, 3, 4, 5, 6) +***** error [a, b] = cheby2 (.5, 40, .2) +***** error [a, b] = cheby2 (3, 40, .2, "invalid") ***** test - X = [27 42 11; 63 48 5; 67 74 93]; - X(:, :, 2) = [15 23 81; 34 60 28; 70 54 38]; - [Y, perm, shifts] = shiftdata(X, 2); - T = [27 63 67; 42 48 74; 11 5 93]; - T(:, :, 2) = [15 34 70; 23 60 54; 81 28 38]; - assert(Y, T); - assert(perm, [2 1 3]); + cheby2 (3, 4, .5); + assert (isrow (ans)); ***** test - X = fix (rand (4, 4, 4, 4) * 100); - [Y, perm, shifts] = shiftdata (X, 3); - T = 0; - for i = 1:3 - for j = 1:3 - for k = 1:2 - for l = 1:2 - T = [T Y(k, i, j, l) - X(i, j, k ,l)]; - endfor - endfor - endfor - endfor - assert (T, zeros (size (T))); -***** error shiftdata () -***** error shiftdata (1, 2, 3) -***** error shiftdata (1, 2.5) -6 tests, 6 passed, 0 known failure, 0 skipped -[inst/db2pow.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/db2pow.m -***** shared db - db = [-10, 0, 10, 20, 25]; -***** assert (db2pow (db), [0.10000, 1.00000, 10.00000, 100.00000, 316.22777], 0.00001) -***** assert (db2pow (db'), [0.10000; 1.00000; 10.00000; 100.00000; 316.22777], 0.00001) -***** error db2pow () -***** error db2pow (1, 2) -4 tests, 4 passed, 0 known failure, 0 skipped -[inst/pei_tseng_notch.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/pei_tseng_notch.m + A = cheby2 (3, 4, .5); + assert (isrow (A)); ***** test - ## 2Hz bandwidth - sf = 800; sf2 = sf/2; - data=[sinetone(49,sf,10,1),sinetone(50,sf,10,1),sinetone(51,sf,10,1)]; - [b, a] = pei_tseng_notch ( 50 / sf2, 2 / sf2 ); - filtered = filter ( b, a, data ); - damp_db = 20 * log10 ( max ( filtered ( end - 1000 : end, : ) ) ); - assert ( damp_db, [ -3 -251.9 -3 ], -0.1 ) + [A, B] = cheby2 (3, 4, .5); + assert (isrow (A)); + assert (isrow (B)); ***** test - ## 1Hz bandwidth - sf = 800; sf2 = sf/2; - data=[sinetone(49.5,sf,10,1),sinetone(50,sf,10,1),sinetone(50.5,sf,10,1)]; - [b, a] = pei_tseng_notch ( 50 / sf2, 1 / sf2 ); - filtered = filter ( b, a, data ); - damp_db = 20 * log10 ( max ( filtered ( end - 1000 : end, : ) ) ); - assert ( damp_db, [ -3 -240.4 -3 ], -0.1 ) + [z, p, g] = cheby2 (3, 4, .5); + assert (iscolumn (z)); + assert (iscolumn (p)); + assert (isscalar (g)); +***** test + [a, b, c, d] = cheby2 (3, 4, .5); + assert (ismatrix (a)); + assert (iscolumn (b)); + assert (isrow (c)); + assert (isscalar (d)); +11 tests, 11 passed, 0 known failure, 0 skipped +[inst/tukeywin.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/tukeywin.m ***** demo - sf = 800; sf2 = sf/2; - data=[[1;zeros(sf-1,1)],sinetone(49,sf,1,1),sinetone(50,sf,1,1),sinetone(51,sf,1,1)]; - [b,a]=pei_tseng_notch ( 50 / sf2, 2/sf2 ); - filtered = filter(b,a,data); + m = 100; + r = 1/3; + w = tukeywin (m, r); + title(sprintf("%d-point Tukey window, R = %d/%d", m, [p, q] = rat(r), q)); + plot(w); +***** assert (tukeywin (1), 1) +***** assert (tukeywin (2), zeros (2, 1)) +***** assert (tukeywin (3), [0; 1; 0]) +***** assert (tukeywin (16, 0), rectwin (16)) +***** assert (tukeywin (16, 1), hanning (16)) +***** error tukeywin () +***** error tukeywin (0.5) +***** error tukeywin (-1) +***** error tukeywin (ones (1, 4)) +***** error tukeywin (1, 2, 3) +10 tests, 10 passed, 0 known failure, 0 skipped +[inst/grpdelay.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/grpdelay.m +***** demo % 1 + %-------------------------------------------------------------- + % From Oppenheim and Schafer, a single zero of radius r=0.9 at + % angle pi should have a group delay of about -9 at 1 and 1/2 + % at zero and 2*pi. + %-------------------------------------------------------------- + grpdelay([1 0.9],[],512,'whole',1); + hold on; + xlabel('Normalized Frequency (cycles/sample)'); + stem([0, 0.5, 1],[0.5, -9, 0.5],'*b;target;'); + hold off; + title ('Zero at z = -0.9'); - clf - subplot ( columns ( filtered ), 1, 1) - plot(filtered(:,1),";Impulse response;") - subplot ( columns ( filtered ), 1, 2 ) - plot(filtered(:,2),";49Hz response;") - subplot ( columns ( filtered ), 1, 3 ) - plot(filtered(:,3),";50Hz response;") - subplot ( columns ( filtered ), 1, 4 ) - plot(filtered(:,4),";51Hz response;") -2 tests, 2 passed, 0 known failure, 0 skipped -[inst/idst.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/idst.m +***** demo % 2 + %-------------------------------------------------------------- + % confirm the group delays approximately meet the targets + % don't worry that it is not exact, as I have not entered + % the exact targets. + %-------------------------------------------------------------- + b = poly([1/0.9*exp(1i*pi*0.2), 0.9*exp(1i*pi*0.6)]); + a = poly([0.9*exp(-1i*pi*0.6), 1/0.9*exp(-1i*pi*0.2)]); + grpdelay(b,a,512,'whole',1); + hold on; + xlabel('Normalized Frequency (cycles/sample)'); + stem([0.1, 0.3, 0.7, 0.9], [9, -9, 9, -9],'*b;target;'); + hold off; + title ('Two Zeros and Two Poles'); +***** demo % 3 + %-------------------------------------------------------------- + % fir lowpass order 40 with cutoff at w=0.3 and details of + % the transition band [.3, .5] + %-------------------------------------------------------------- + subplot(211); + Fs = 8000; % sampling rate + Fc = 0.3*Fs/2; % lowpass cut-off frequency + nb = 40; + b = fir1(nb,2*Fc/Fs); % matlab freq normalization: 1=Fs/2 + [H,f] = freqz(b,1,[],1); + [gd,f] = grpdelay(b,1,[],1); + plot(f,20*log10(abs(H))); + title(sprintf('b = fir1(%d,2*%d/%d);',nb,Fc,Fs)); + xlabel('Normalized Frequency (cycles/sample)'); + ylabel('Amplitude Response (dB)'); + grid('on'); + subplot(212); + del = nb/2; % should equal this + plot(f,gd); + title(sprintf('Group Delay in Pass-Band (Expect %d samples)',del)); + ylabel('Group Delay (samples)'); + axis([0, 0.2, del-1, del+1]); +***** demo % 4 + %-------------------------------------------------------------- + % IIR bandstop filter has delays at [1000, 3000] + %-------------------------------------------------------------- + Fs = 8000; + [b, a] = cheby1(3, 3, 2*[1000, 3000]/Fs, 'stop'); + [H,f] = freqz(b,a,[],Fs); + [gd,f] = grpdelay(b,a,[],Fs); + subplot(211); + plot(f,abs(H)); + title('[b,a] = cheby1(3, 3, 2*[1000, 3000]/Fs, "stop");'); + xlabel('Frequency (Hz)'); + ylabel('Amplitude Response'); + grid('on'); + subplot(212); + plot(f,gd); + title('[gd,f] = grpdelay(b,a,[],Fs);'); + ylabel('Group Delay (samples)'); +***** test % 00 + [gd1,w] = grpdelay([0,1]); + [gd2,w] = grpdelay([0,1],1); + assert(gd1,gd2,10*eps); +***** test % 0A + [gd,w] = grpdelay([0,1],1,4); + assert(gd,[1;1;1;1]); + assert(w,pi/4*[0:3]',10*eps); +***** test % 0B + [gd,w] = grpdelay([0,1],1,4,'whole'); + assert(gd,[1;1;1;1]); + assert(w,pi/2*[0:3]',10*eps); +***** test % 0C + [gd,f] = grpdelay([0,1],1,4,0.5); + assert(gd,[1;1;1;1]); + assert(f,1/16*[0:3]',10*eps); +***** test % 0D + [gd,w] = grpdelay([0,1],1,4,'whole',1); + assert(gd,[1;1;1;1]); + assert(w,1/4*[0:3]',10*eps); +***** test % 0E + [gd,f] = grpdelay([1 -0.9j],[],4,'whole',1); + gd0 = 0.447513812154696; gdm1 =0.473684210526316; + assert(gd,[gd0;-9;gd0;gdm1],20*eps); + assert(f,1/4*[0:3]',10*eps); +***** test % 1A: + gd= grpdelay(1,[1,.9],2*pi*[0,0.125,0.25,0.375]); + assert(gd, [-0.47368;-0.46918;-0.44751;-0.32316],1e-5); +***** test % 1B: + gd= grpdelay(1,[1,.9],[0,0.125,0.25,0.375],1); + assert(gd, [-0.47368;-0.46918;-0.44751;-0.32316],1e-5); +***** test % 2: + gd = grpdelay([1,2],[1,0.5,.9],4); + assert(gd,[-0.29167;-0.24218;0.53077;0.40658],1e-5); +***** test % 3 + b1=[1,2];a1f=[0.25,0.5,1];a1=fliplr(a1f); + % gd1=grpdelay(b1,a1,4); + gd=grpdelay(conv(b1,a1f),1,4)-2; + assert(gd, [0.095238;0.239175;0.953846;1.759360],1e-5); +***** test % 4 + warning ("off", "signal:grpdelay-singularity", "local"); + Fs = 8000; + [b, a] = cheby1(3, 3, 2*[1000, 3000]/Fs, 'stop'); + [h, w] = grpdelay(b, a, 256, 'half', Fs); + [h2, w2] = grpdelay(b, a, 512, 'whole', Fs); + assert (size(h), size(w)); + assert (length(h), 256); + assert (size(h2), size(w2)); + assert (length(h2), 512); + assert (h, h2(1:256)); + assert (w, w2(1:256)); +***** test % 5 + a = [1 0 0.9]; + b = [0.9 0 1]; + [dh, wf] = grpdelay(b, a, 512, 'whole'); + [da, wa] = grpdelay(1, a, 512, 'whole'); + [db, wb] = grpdelay(b, 1, 512, 'whole'); + assert(dh,db+da,1e-5); ***** test - x = log(gausswin(32)); - assert(x, idst(dst(x)), 100*eps) -1 test, 1 passed, 0 known failure, 0 skipped + DR= [1.00000 -0.00000 -3.37219 0.00000 ... + 5.45710 -0.00000 -5.24394 0.00000 ... + 3.12049 -0.00000 -1.08770 0.00000 0.17404]; + N = [-0.0139469 -0.0222376 0.0178631 0.0451737 ... + 0.0013962 -0.0259712 0.0016338 0.0165189 ... + 0.0115098 0.0095051 0.0043874]; + assert (nthargout (1:2, @grpdelay, N, DR, 1024), + nthargout (1:2, @grpdelay, N', DR', 1024)); +13 tests, 13 passed, 0 known failure, 0 skipped [inst/residuez.m] >>>>> /build/reproducible-path/octave-signal-1.4.5/inst/residuez.m ***** test @@ -7008,115 +8572,97 @@ assert(p(is), [-0.5; -1], 100*eps); assert(k, [0 1], 100*eps); 10 tests, 10 passed, 0 known failure, 0 skipped -[inst/fracshift.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/fracshift.m +[inst/ifht.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/ifht.m +***** assert(ifht(fht(1:4)),[1 2 3 4]) +1 test, 1 passed, 0 known failure, 0 skipped +[inst/db2pow.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/db2pow.m +***** shared db + db = [-10, 0, 10, 20, 25]; +***** assert (db2pow (db), [0.10000, 1.00000, 10.00000, 100.00000, 316.22777], 0.00001) +***** assert (db2pow (db'), [0.10000; 1.00000; 10.00000; 100.00000; 316.22777], 0.00001) +***** error db2pow () +***** error db2pow (1, 2) +4 tests, 4 passed, 0 known failure, 0 skipped +[inst/isminphase.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/isminphase.m +***** demo + b = [3 1]; + a = [1 .5]; + f = isminphase (b, a) + ## test input validation +***** error n = isminphase () +***** error n = isminphase (1, 1, 1, 1) +***** error n = isminphase (1, 1, 1, 1, 1) +***** error n = isminphase ([1:10]', 1) +***** error n = isminphase (1, [1:10]') +***** error n = isminphase ([1:10]', [1:10]') +***** error n = isminphase (1:10, 1:10, 1:10) +***** error n = isminphase (ones (3), ones (3)) ***** test - d = [1.5 7/6]; - N = 1024; - t = ((0:N-1)-N/2).'; - tt = bsxfun (@minus, t, d); - err1= err2 = zeros(N/2,1); - for n = 0:N/2-1, - phi0 = 2*pi*rand; - f0 = n/N; - sigma = N/4; - x = exp(-t.^2/(2*sigma)).*sin(2*pi*f0*t + phi0); - xx = exp(-tt.^2/(2*sigma)).*sin(2*pi*f0*tt + phi0); - [y,h] = fracshift(x, d(1)); - err1(n+1) = max (abs (y - xx(:,1))); - [y,h] = fracshift(x, d(2)); - err2(n+1) = max (abs (y - xx(:,2))); - endfor - rolloff = .1; - rejection = 10^-3; - idx_inband = 1:ceil((1-rolloff)*N/2)-1; - assert (max (err1(idx_inband)) < rejection); - assert (max (err2(idx_inband)) < rejection); + b = [3 1]; + a = [1 .5]; + f = isminphase (b, a); + assert (f, true) ***** test - N = 1024; - p = 6; - q = 7; - d1 = 64; - d2 = d1*p/q; - t = 128; - - [b a] = butter (10,.25); - n = zeros (N, 1); - n(N/2+(-t:t)) = randn(2*t+1,1); - n = filter(b,a,n); - n1 = fracshift(n,d1); - n1 = resample(n1,p,q); - n2 = resample(n,p,q); - n2 = fracshift(n2,d2); - err = abs (n2 - n1); - rejection = 10^-3; - assert(max (err) < rejection); -***** test #integer shift similar similar to non-integer - N = 1024; - t = linspace(0, 1, N).'; - x = exp(-t.^2/2/0.25^2).*sin(2*pi*10*t); - d = 10; - y = fracshift(x, d); - yh = fracshift(x, d+1e-8); - assert(y, yh, 1e-8) -***** warning fracshift([1 2 3 2 1], 3, h=0.5); #integer shift and filter provided -***** test #bug 52758 - x = [0 1 0 0 0 0 0 0]; - y = fracshift(x, 1); - assert (size(x) == size(y)) -***** test #bug 47387 - N = 1024; - t = linspace(0, 1, N).'; - x = exp(-t.^2/2/0.25^2).*sin(2*pi*10*t); - dt = 0.25; - d = dt / (t(2) - t(1)); - y = fracshift(x, d); - L = 37; - _t = (-L:L).'; - ideal_filter = sinc (_t - (d - fix (d))); - m = 2 * L; - _t = (0:m).' - (d - fix (d)); - beta = 5.6533; - _t = 2 * beta / m * sqrt (_t .* (m - _t)); - w = besseli (0, _t) / besseli (0, beta); - h = w .* ideal_filter; - yh = fracshift(x, d, h); - assert(y, yh, 1e-8) -***** demo - N = 1024; - t = linspace (0, 1, N).'; - x = exp(-t.^2/2/0.25^2).*sin(2*pi*10*t); - - dt = 0.25; - d = dt / (t(2) - t(1)); - y = fracshift(x, d); - - plot(t,y,'r-;shifted;', t, x, 'k-;original;') - axis tight - xlabel ('time') - ylabel ('signal') -6 tests, 6 passed, 0 known failure, 0 skipped -[inst/hann.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/hann.m -***** assert (hann (1), 1); -***** assert (hann (2), zeros (2, 1)); -***** assert (hann (16), flipud (hann (16)), 10*eps); -***** assert (hann (15), flipud (hann (15)), 10*eps); + [b, a] = butter (1, .5); + f = isminphase (b, a); + assert (f, false) ***** test - N = 15; - A = hann (N); - assert (A(ceil (N/2)), 1); -***** assert (hann (15), hann (15, "symmetric")); -***** assert (hann (16)(1:15), hann (15, "periodic")); + [b, a] = butter (8, .5); + f = isminphase (b, a); + assert (f, false) ***** test - N = 16; - A = hann (N, "periodic"); - assert (A (N/2 + 1), 1); -***** error hann () -***** error hann (0.5) -***** error hann (-1) -***** error hann (1, "invalid") + b = 1.25^2 * conv (conv (conv ([1 -0.9*e^(-j*0.6*pi)], [1 -0.9*e^(j*0.6*pi)]), [1 -0.8*e^(-j*0.8*pi)]), [1 -0.8*e^(j*0.8*pi)]); + a = 1; + f = isminphase (b, a); + assert (f, true) 12 tests, 12 passed, 0 known failure, 0 skipped +[inst/phasez.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/phasez.m +***** demo + N = 2; + b = ones (1, N)/N; + a = 1; + [phi, w] = phasez (b, a) + ## test input validation +***** error n = phasez () +***** error n = phasez (1, 1, 1, 1, 1) +***** error n = phasez (1:10, 1:10, 1:10) +***** error n = phasez (ones (3), ones (3)) +***** test + % moving average + N = 2; + b = ones (1, N)/N; + a = 1; + [phi, w] = phasez (b, a); + PHI = -w * (N-1) /2; + assert (phi, PHI, eps^(3/5)) +***** test + % moving average + N = 5; + b = ones (1, N)/N; + a = 1; + [phi, w] = phasez (b, a); + PHI = -w * (N-1) /2; + assert (phi, PHI, eps^(3/5)) +***** test + % Oppenheim - Example 5.6 - 2nd-Order IIR System + % + % 1 + % H(z) = --------------------------- + % 1 − 2r cos θz^−1 + r^2 z^−2 + % + % ang(H(e^jω)) = − arctan[ r sin(ω − θ) / (1 − r cos(ω − θ)) ] − arctan[ r sin(ω + θ) / (1 − r cos(ω + θ)) ] + % + r = 0.5; theta = pi/4; + b = 1; + a = [ 1 -2*r*cos(theta) r^2]; + [phi, w] = phasez (b, a); + PHI = - atan ( r*sin (w - theta) ./ (1 - r*cos (w - theta)) ) - atan ( r*sin (w + theta) ./ (1 - r*cos (w+theta)) ); + assert (phi, PHI, eps^(3/5)) +7 tests, 7 passed, 0 known failure, 0 skipped [inst/sos2ss.m] >>>>> /build/reproducible-path/octave-signal-1.4.5/inst/sos2ss.m ***** test @@ -7125,321 +8671,105 @@ [a, b, c, d] = sos2ss (sos, g); assert ({a, b, c, d}, {-0.5, 0.5, 1, 1}); 1 test, 1 passed, 0 known failure, 0 skipped -[inst/filtic.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/filtic.m -***** test - ## Simple low pass filter - b=[0.25 0.25]; - a=[1.0 -0.5]; - zf_ref=0.75; - zf=filtic(b,a,[1.0],[1.0]); - assert(zf,zf_ref,8*eps); - -***** test - ## Simple high pass filter - b=[0.25 -0.25]; - a=[1.0 0.5]; - zf_ref = [-0.25]; - zf=filtic(b,a,[0.0],[1.0]); - assert(zf,zf_ref,8*eps); - -***** test - ## Second order cases - [b,a]=butter(2,0.4); - N=1000; ## Long enough for filter to settle - xx=ones(1,N); - [yy,zf_ref] = filter(b,a,xx); - x=xx(N:-1:N-1); - y=yy(N:-1:N-1); - zf = filtic(b,a,y,x); - assert(zf,zf_ref,8*eps); - - xx = cos(2*pi*linspace(0,N-1,N)/8); - [yy,zf_ref] = filter(b,a,xx); - x=xx(N:-1:N-1); - y=yy(N:-1:N-1); - zf = filtic(b,a,y,x); - assert(zf,zf_ref,8*eps); - -***** test - ## Third order filter - takes longer to settle - N=10000; - [b,a]=cheby1(3,10,0.5); - xx=ones(1,N); - [yy,zf_ref] = filter(b,a,xx); - x=xx(N:-1:N-2); - y=yy(N:-1:N-2); - zf = filtic(b,a,y,x); - assert(zf,zf_ref,8*eps); - -***** test - ## Eight order high pass filter - N=10000; - [b,a]=butter(8,0.2); - xx = cos(2*pi*linspace(0,N-1,N)/8); - [yy,zf_ref] = filter(b,a,xx); - x=xx(N:-1:N-7); - y=yy(N:-1:N-7); - zf = filtic(b,a,y,x); - assert(zf,zf_ref,8*eps); - -***** test - ## Case with 3 args - [b,a]=butter(2,0.4); - N=100; - xx=[ones(1,N) zeros(1,2)]; - [yy,zf_ref] = filter(b,a,xx); - y=[yy(N+2) yy(N+1)]; - zf=filtic(b,a,y); - assert(zf,zf_ref,8*eps); -***** test - a = [2, -3, 1]; - b = [4, -3]; - y = [0; 1]; - z = filtic (b, a, y); - assert (z, [-0.5; 0]); -7 tests, 7 passed, 0 known failure, 0 skipped -[inst/zerocrossing.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/zerocrossing.m -***** test - x = linspace(0,1,100); - y = rand(1,100)-0.5; - x0= zerocrossing(x,y); - y0 = interp1(x,y,x0); - assert(norm(y0,inf), 0, 100*eps) -***** test - x = linspace(0,1,100); - y = rand(1,100)-0.5; - y(10:20) = 0; - x0= zerocrossing(x,y); - y0 = interp1(x,y,x0); - assert(norm(y0,inf), 0, 100*eps) -***** demo - x = linspace(0,1,100); - y = rand(1,100)-0.5; - x0= zerocrossing(x,y); - y0 = interp1(x,y,x0); - plot(x,y,x0,y0,'x') -***** demo - x = linspace(0,1,100); - y = rand(1,100)-0.5; - y(10:20) = 0; - x0= zerocrossing(x,y); - y0 = interp1(x,y,x0); - plot(x,y,x0,y0,'x') -2 tests, 2 passed, 0 known failure, 0 skipped -[inst/bohmanwin.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/bohmanwin.m -***** assert (bohmanwin (1), 1) -***** assert (bohmanwin (2), zeros (2, 1)) -***** error bohmanwin () -***** error bohmanwin (0.5) -***** error bohmanwin (-1) -***** error bohmanwin (ones (1, 4)) -***** error bohmanwin (1, 2) -7 tests, 7 passed, 0 known failure, 0 skipped -[inst/cceps.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cceps.m -***** test - x = randn (256, 1); - c = cceps (x); - assert (size (c), size (x)) -***** error cceps () -***** error cceps (1, 2, 3) -***** error cceps (ones (4)) -***** error cceps (0) -***** error cceps (zeros (10, 1)) -6 tests, 6 passed, 0 known failure, 0 skipped -[inst/buffer.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/buffer.m -***** error (buffer(1:10, 4.1)) -***** assert (buffer(1:10, 4), reshape([1:10,0,0],[4,3])) -***** assert (buffer(1:10, 4, 1), reshape([0:3,3:6,6:9,9,10,0,0],[4,4])) -***** assert (buffer(1:10, 4, 2), reshape ([0,0:2,1:4,3:6,5:8,7:10],[4,5])) -***** assert (buffer(1:10, 4, 3), [0,0,0:7;0,0:8;0:9;1:10]) -***** error (buffer(1:10, 4, 3.1)) -***** error (buffer(1:10, 4, 4)) -***** assert (buffer(1:10, 4, -1), reshape([1:4,6:9],[4,2])) -***** assert (buffer(1:10, 4, -2), reshape([1:4,7:10],[4,2])) -***** assert (buffer(1:10, 4, -3), reshape([1:4,8:10,0],[4,2])) -***** assert (buffer(1:10, 4, 1, 11), reshape([11,1:3,3:6,6:9,9,10,0,0],[4,4])) -***** error (buffer(1:10, 4, 1, [10,11])) -***** assert (buffer(1:10, 4, 1, 'nodelay'), reshape([1:4,4:7,7:10],[4,3])) -***** error (buffer(1:10, 4, 1, 'badstring')) -***** assert (buffer(1:10, 4, 2,'nodelay'), reshape ([1:4,3:6,5:8,7:10],[4,4])) -***** assert (buffer(1:10, 4, 3, [11,12,13]),[11,12,13,1:7;12,13,1:8;13,1:9;1:10]) -***** assert (buffer(1:10, 4, 3, 'nodelay'),[1:8;2:9;3:10;4:10,0]) -***** assert (buffer(1:11,4,-2,1),reshape([2:5,8:11],4,2)) -***** test - [y, z] = buffer(1:12,4); - assert (y, reshape(1:12,4,3)); - assert (z, zeros (1,0)); -***** test - [y, z] = buffer(1:11,4); - assert (y, reshape(1:8,4,2)); - assert (z, [9, 10, 11]); -***** test - [y, z] = buffer([1:12]',4); - assert (y, reshape(1:12,4,3)); - assert (z, zeros (0,1)); -***** test - [y, z] = buffer([1:11]',4); - assert (y, reshape(1:8,4,2)); - assert (z, [9; 10; 11]); -***** test - [y,z,opt] = buffer(1:15,4,-2,1); - assert (y, reshape([2:5,8:11],4,2)); - assert (z, [14, 15]); - assert (opt, 0); -***** test - [y,z,opt] = buffer(1:11,4,-2,1); - assert (y, reshape([2:5,8:11],4,2)); - assert (z, zeros (1,0)); - assert (opt, 2); -***** test - [y,z,opt] = buffer([1:15]',4,-2,1); - assert (y, reshape([2:5,8:11],4,2)); - assert (z, [14; 15]); - assert (opt, 0); -***** test - [y,z,opt] = buffer([1:11]',4,-2,1); - assert (y, reshape([2:5,8:11],4,2)); - assert (z, zeros (0, 1)); - assert (opt, 2); -***** test - [y,z,opt] = buffer([1:11],5,2,[-1,0]); - assert (y, reshape ([-1:3,2:6,5:9],[5,3])); - assert (z, [10, 11]); - assert (opt, [8; 9]); -***** test - [y,z,opt] = buffer([1:11]',5,2,[-1,0]); - assert (y, reshape ([-1:3,2:6,5:9],[5,3])); - assert (z, [10; 11]); - assert (opt, [8; 9]); -***** test - [y, z, opt] = buffer (1:10, 6, 4); - assert (y, [0 0 1:2:5; 0 0 2:2:6; 0 1:2:7; 0 2:2:8; 1:2:9; 2:2:10]) - assert (z, zeros (1, 0)) - assert (opt, [7; 8; 9; 10]) -29 tests, 29 passed, 0 known failure, 0 skipped -[inst/cheb2ap.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cheb2ap.m -***** error cheb2ap (-1, 3) -***** error cheb2ap (3, -1) -***** demo - w=0:0.01:1000; - [z, p, k] = cheb2ap (3, 3); - [b, a] = zp2tf (z, p, k); - Gs = freqs (b, a, w); - semilogx (w, abs (Gs)); - xlabel('Frequency in rad/sec') - ylabel('Magnitude of G(s)'); - title('Type 2 Chebyshev Low-Pass Filter, k=3, 3 dB ripple in stop band') - grid; -2 tests, 2 passed, 0 known failure, 0 skipped -[inst/unshiftdata.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/unshiftdata.m -***** test - x = 1:5; - [y, perm, shifts] = shiftdata (x); - x2 = unshiftdata (y, perm, shifts); - assert (x, x2); -***** test - X = fix (rand (3, 3) * 100); - [Y, perm, shifts] = shiftdata (X, 2); - X2 = unshiftdata (Y, perm, shifts); - assert (X, X2); -***** test - X = fix (rand (4, 4, 4, 4) * 100); - [Y, perm, shifts] = shiftdata (X, 3); - X2 = unshiftdata (Y, perm, shifts); - assert (X, X2); -***** test - X = fix (rand (1, 1, 3, 4) * 100); - [Y, perm, shifts] = shiftdata (X); - X2 = unshiftdata (Y, perm, shifts); - assert (X, X2); -***** error unshiftdata () -***** error unshiftdata (1, 2) -***** error unshiftdata (1, 2, 3, 4) -***** error unshiftdata (1, 2.5) -***** error unshiftdata (1, [], 2.5) -***** error unshiftdata (1, [], []) -10 tests, 10 passed, 0 known failure, 0 skipped -[inst/specgram.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/specgram.m -***** shared S,f,t,x - Fs=1000; - x = chirp([0:1/Fs:2],0,2,500); # freq. sweep from 0-500 over 2 sec. - step=ceil(20*Fs/1000); # one spectral slice every 20 ms - window=ceil(100*Fs/1000); # 100 ms data window - [S, f, t] = specgram(x); - ## test of returned shape -***** assert (rows(S), 128) -***** assert (columns(f), rows(S)) -***** assert (columns(t), columns(S)) -***** test [S, f, t] = specgram(x'); -***** assert (rows(S), 128) -***** assert (columns(f), rows(S)); -***** assert (columns(t), columns(S)); -***** error (isempty(specgram([]))); -***** error (isempty(specgram([1, 2 ; 3, 4]))); -***** error (specgram) +[inst/isallpass.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/isallpass.m ***** demo - Fs=1000; - x = chirp([0:1/Fs:2],0,2,500); # freq. sweep from 0-500 over 2 sec. - step=ceil(20*Fs/1000); # one spectral slice every 20 ms - window=ceil(100*Fs/1000); # 100 ms data window - - ## test of automatic plot - [S, f, t] = specgram(x); - specgram(x, 2^nextpow2(window), Fs, window, window-step); -***** #demo # FIXME: Enable once we have an audio file to demo - ## Speech spectrogram - [x, Fs] = auload(file_in_loadpath("sample.wav")); # audio file - step = fix(5*Fs/1000); # one spectral slice every 5 ms - window = fix(40*Fs/1000); # 40 ms data window - fftn = 2^nextpow2(window); # next highest power of 2 - [S, f, t] = specgram(x, fftn, Fs, window, window-step); - S = abs(S(2:fftn*4000/Fs,:)); # magnitude in range 0>>>> /build/reproducible-path/octave-signal-1.4.5/inst/isstable.m + # H(z) = (b1 - z^-1) * (b2 - z^-1) / ((1 - b1*z^-1) * (1 - b2*z^-1)) + b1 = 0.5 * (1 + i); + b2 = 0.7 * (cos (pi/6) + i*sin (pi/6)); + b = conv ([b1 -1], [b2 -1]); + a = conv ([1 (-1)*conj(b1)],[1 (-1)*conj(b2)]); + freqz (b, a); + f = isallpass (b, a) + ## test input validation +***** error n = isallpass () +***** error n = isallpass (1) +***** error n = isallpass (1, 1, 1) +***** error n = isallpass (1, 1, 1, 1) +***** error n = isallpass (1, 1, 1, 1, 1) +***** error n = isallpass ([1:10]', 1) +***** error n = isallpass (1, [1:10]') +***** error n = isallpass ([1:10]', [1:10]') +***** error n = isallpass (1:10, 1:10, 1:10) +***** error n = isallpass (ones (3), ones (3)) ***** test - b = [1 2 3 4 5 5 1 2]; - a = []; - assert (isstable (b,a), true) + b = [(1+i)/2 -1]; + a = [1 -(1-i)/2]; + f = isallpass (b, a); + assert (f, true) ***** test - b = [1 2 3 4 5 5 1 2]; - a = [4 5 6 7 9 10 4 6]; - assert (isstable (b,a), false) + b = [(1+i)/2 -1]; + a = [-1 (1-i)/2]; + f = isallpass (b, a); + assert (f, true) ***** test - b = [1 2 3 4 5 5 1 2]; - a = [4 5 6 7 9 10 4 6]; - a = polystab(a); - assert (isstable (b,a), true) + [b, a] = butter (1, 0.5); + f = isallpass (b, a); + assert (f, false) ***** test - [z,p,g] = butter(6,0.7,'high'); - sos = zp2sos(z,p,g); - assert (isstable(sos) , true) + b1 = 0.5 * (1 + i); + b2 = 0.7 * (cos (pi/6) + i*sin (pi/6)); + b = conv ([b1 -1], [b2 -1]); + a = conv ([1 -conj(b1)],[1, -conj(b2)]); + f = isallpass (b, a); + assert (f, true) +14 tests, 14 passed, 0 known failure, 0 skipped +[inst/xcorr2.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/xcorr2.m +***** test # basic usage + a = magic (5); + b = [6 13 22; 10 18 23; 8 15 23]; + c = [391 807 519 391 473 289 120 + 920 1318 1045 909 1133 702 278 + 995 1476 1338 1534 2040 1161 426 + 828 1045 1501 2047 2108 1101 340 + 571 1219 2074 2155 1896 821 234 + 473 1006 1643 1457 946 347 108 + 242 539 850 477 374 129 54]; + assert (xcorr2 (a, b), c); +***** shared a, b, c, row_shift, col_shift + row_shift = 18; + col_shift = 20; + a = randi (255, 30, 30); + b = a(row_shift-10:row_shift, col_shift-7:col_shift); + c = xcorr2 (a, b, "coeff"); +***** assert (nthargout ([1 2], @find, c == max (c(:))), {row_shift, col_shift}); # should return exact coordinates + m = rand (size (b)) > 0.5; + b(m) = b(m) * 0.95; + b(!m) = b(!m) * 1.05; + c = xcorr2 (a, b, "coeff"); +***** assert (nthargout ([1 2], @find, c == max (c(:))), {row_shift, col_shift}); # even with some small noise, should return exact coordinates +***** test # coeff of autocorrelation must be same as negative of correlation by additive inverse + a = 10 * randn (100, 100); + auto = xcorr2 (a, "coeff"); + add_in = xcorr2 (a, -a, "coeff"); + assert ([min(auto(:)), max(auto(:))], -[max(add_in(:)), min(add_in(:))]); 4 tests, 4 passed, 0 known failure, 0 skipped -[inst/rssq.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/rssq.m -***** assert (rssq ([]), 0) -***** assert (rssq ([1 2 -1]), sqrt (6)) -***** assert (rssq ([1 2 -1]'), sqrt (6)) -***** assert (rssq ([1 2], 3), [1 2]) -***** error rssq () -***** error rssq (1, 2, 3) -***** error rssq (1, 1.5) -***** error rssq (1, -1) -8 tests, 8 passed, 0 known failure, 0 skipped +[inst/nuttallwin.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/nuttallwin.m +***** assert (nuttallwin (1), 1) +***** assert (nuttallwin (2), zeros (2, 1), eps) +***** assert (nuttallwin (15), flipud (nuttallwin (15)), 10*eps); +***** assert (nuttallwin (16), flipud (nuttallwin (16)), 10*eps); +***** assert (nuttallwin (15), nuttallwin (15, "symmetric")); +***** assert (nuttallwin (16)(1:15), nuttallwin (15, "periodic")); +***** error nuttallwin () +***** error nuttallwin (0.5) +***** error nuttallwin (-1) +***** error nuttallwin (ones (1, 4)) +***** error nuttallwin (1, 2) +***** error nuttallwin (1, "invalid") +12 tests, 12 passed, 0 known failure, 0 skipped +[inst/chebwin.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/chebwin.m +***** assert (chebwin (1), 1) +***** assert (chebwin (2), ones (2, 1)) +***** error chebwin () +***** error chebwin (0.5) +***** error chebwin (-1) +***** error chebwin (ones (1, 4)) +***** error chebwin (1, 2, 3) +7 tests, 7 passed, 0 known failure, 0 skipped [inst/ultrwin.m] >>>>> /build/reproducible-path/octave-signal-1.4.5/inst/ultrwin.m ***** test @@ -7546,97 +8876,82 @@ % top to bottom: Ultraspherical, Dolph-Chebyshev, and Kaiser % windows, with lengths 153, 165, and 159 respectively. 5 tests, 5 passed, 0 known failure, 0 skipped -[inst/bitrevorder.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/bitrevorder.m -***** assert (bitrevorder (0), 0); -***** assert (bitrevorder (0:1), 0:1); -***** assert (bitrevorder ([0:1]'), [0:1]'); -***** assert (bitrevorder (0:7), [0 4 2 6 1 5 3 7]); -***** assert (bitrevorder ([0:7]'), [0 4 2 6 1 5 3 7]'); -***** assert (bitrevorder ([0:7]*i), [0 4 2 6 1 5 3 7]*i); -***** assert (bitrevorder ([0:7]'*i), [0 4 2 6 1 5 3 7]'*i); -***** assert (bitrevorder (0:15), [0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15]); -***** error bitrevorder (); -***** error bitrevorder (1, 2); -***** error bitrevorder ([]); -***** error bitrevorder (0:2); -12 tests, 12 passed, 0 known failure, 0 skipped -[inst/peak2peak.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/peak2peak.m -***** test - X = [23 42 85; 62 46 65; 18 40 28]; - Y = peak2peak (X); - assert (Y, [44 6 57]); - Y = peak2peak (X, 1); - assert (Y, [44 6 57]); - Y = peak2peak (X, 2); - assert (Y, [62; 19; 22]); +[inst/rms.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/rms.m +***** assert (rms (0), 0) +***** assert (rms (1), 1) +***** assert (rms ([1 2 -1]), sqrt (2)) +***** assert (rms ([1 2 -1]'), sqrt (2)) +***** assert (rms ([1 2], 3), [1 2]) +***** error rms () +***** error rms (1, 2, 3) +***** error rms (1, 1.5) +***** error rms (1, -1) +9 tests, 9 passed, 0 known failure, 0 skipped +[inst/rceps.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/rceps.m ***** test - X = [71 62 33]; - X(:, :, 2) = [88 36 21]; - X(:, :, 3) = [83 46 85]; - Y = peak2peak (X); - T = [38]; - T(:, :, 2) = [67]; - T(:, :, 3) = [39]; - assert (Y, T); + ## accepts matrices + x = randn (32, 3); + [y, xm] = rceps (x); + ## check the mag-phase response of the reproduction + hx = fft (x); + hxm = fft (xm); + assert (abs (hx), abs (hxm), 200*eps); # good magnitude response match + ## FIXME: test for minimum phase? Stop using random datasets! + #assert (arg (hx) != arg (hxm)); # phase mismatch ***** test - X = [71 72 22; 16 22 50; 29 44 14]; - X(:, :, 2) = [10 15 62; 1 94 30; 72 43 53]; - X(:, :, 3) = [57 98 32; 84 95 51; 25 24 0]; - Y = peak2peak (X); - T = [55 50 36]; - T(:, :, 2) = [71 79 32]; - T(:, :, 3) = [59 74 51]; - assert (Y, T); - Y = peak2peak (X, 2); - T = [50; 34; 30]; - T(:, :, 2) = [52; 93; 29]; - T(:, :, 3) = [66; 44; 25]; - assert (Y, T); - Y = peak2peak (X, 3); - T = [61 83 40; 83 73 21; 47 20 53]; - assert (Y, T); + ## accepts column and row vectors + x = randn (256, 1); + [y, xm] = rceps (x); + [yt, xmt] = rceps (x.'); + assert (yt.', y, 1e-14); + assert (xmt.', xm, 1e-14); ***** test - X = [60 61; 77 77]; - X(:, :, 2) = [24 24; 22 74]; - temp = [81 87; 88 62]; - temp(:, :, 2) = [20 83; 81 18]; - X(:, :, :, 2) = temp; - Y = peak2peak (X); - T = [17 16]; - T(:, :, 2) = [2 50]; - T2 = [7 25]; - T2(:, :, 2) = [61 65]; - T(:, :, :, 2) = T2; - assert (Y, T); -***** error peak2peak () -***** error peak2peak (1, 2, 3) -***** error peak2peak (1, 1.5) -***** error peak2peak (1, 0) -8 tests, 8 passed, 0 known failure, 0 skipped -[inst/cconv.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cconv.m -***** shared x - x = [1, 2, 3, 4, 5]; -***** assert (cconv (x, 1), [1, 2, 3, 4, 5], 2*eps) -***** assert (cconv (x', 1), [1; 2; 3; 4; 5], 2*eps) -***** assert (real (cconv (x, [1 1])), [1, 3, 5, 7, 9, 5], 2*eps) -***** assert (cconv (x, [1 1], 3), [8, 12, 10]) -***** assert (cconv ([2 1 2 1], [1 2 3 4]), [2 5 10 16 12 11 4], 1e-14) -***** assert (cconv ([2 1 2 1], [1 2 3 4], 4), [14 16 14 16]) -***** assert (cconv ([2 1 2 1], [1 2 3 4], 3), [22 17 21]) -***** assert (cconv ([2 1 2 1], [1 2 3 4], 2), [28 32]) -***** assert (cconv ([2 1 2 1], [1 2 3 4], 1), 60) -***** assert (cconv (x*j, 1), [1j, 2j, 3j, 4j, 5j]) -***** assert (cconv (x'*j, 1), [1j; 2j; 3j; 4j; 5j]) -***** error cconv () -***** error cconv (1) -***** error cconv (1, 1, [1 1]) -***** error cconv (ones (2, 2), 1) -***** error cconv (1, ones (2, 2)) -***** error cconv (1, 1, 3.5) -17 tests, 17 passed, 0 known failure, 0 skipped + x = randn (33, 4); + [y, xm] = rceps (x); + assert (size (y), size (x)); + assert (size (xm), size (x)); +***** error rceps +***** error rceps (1, 2) +***** error rceps (0) +***** error rceps (zeros (10, 1)) +***** demo + f0 = 70; Fs = 10000; # 100 Hz fundamental, 10 kHz sampling rate + a = real (poly (0.985 * exp (1i * pi * [0.1, -0.1, 0.3, -0.3]))); # two formants + s = 0.05 * randn (1024, 1); # Noise excitation signal + s(floor (1:Fs/f0:length (s))) = 1; # Impulse glottal wave + x = filter (1, a, s); # Speech signal in x + [y, xm] = rceps (x); # cepstrum and minimum phase x + [hx, w] = freqz (x, 1, [], Fs); + hxm = freqz (xm); + figure (1); + subplot (311); + len = 1000 * fix (min (length (x), length (xm)) / 1000); + plot ([0:len-1] * 1000 / Fs, x(1:len), "b;signal;", ... + [0:len-1] * 1000 / Fs, xm(1:len), "g;reconstruction;"); + ylabel ("Amplitude"); + xlabel ("Time (ms)"); + subplot (312); + axis ("ticy"); + plot (w, log (abs (hx)), ";magnitude;", ... + w, log (abs (hxm)), ";reconstruction;"); + xlabel ("Frequency (Hz)"); + subplot (313); + axis ("on"); + plot (w, unwrap (arg (hx)) / (2 * pi), ";phase;", ... + w, unwrap (arg (hxm)) / (2 * pi), ";reconstruction;"); + xlabel ("Frequency (Hz)"); + len = 1000 * fix (length (y) / 1000); + figure (2); + plot ([0:len-1] * 1000 / Fs, y(1:len), ";cepstrum;"); + ylabel ("Amplitude"); + xlabel ("Quefrency (ms)"); + %------------------------------------------------------------- + % confirm the magnitude spectrum is identical in the signal + % and the reconstruction and that there are peaks in the + % cepstrum at 14 ms intervals corresponding to an F0 of 70 Hz. +7 tests, 7 passed, 0 known failure, 0 skipped [inst/upsamplefill.m] >>>>> /build/reproducible-path/octave-signal-1.4.5/inst/upsamplefill.m ***** assert(upsamplefill([1,3,5],2),[1,2,3,2,5,2]); @@ -7646,44 +8961,195 @@ ***** assert(upsamplefill([1,3,5],2,true),[1,1,1,3,3,3,5,5,5]); ***** assert(upsamplefill([1;3;5],2,true),[1;1;1;3;3;3;;5;5;5]); 6 tests, 6 passed, 0 known failure, 0 skipped -[inst/xcov.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/xcov.m -***** error xcov () -***** test - x = 1:5; - [c, l] = xcov(x); - assert(c, [-4.0 -4.0 -1.0 4.0 10.0 4.0 -1.0 -4.0 -4.0], 2*eps) - assert(l, [-4 -3 -2 -1 0 1 2 3 4]) -***** test - x = 1:5; - y = 1:5; - [c, l] = xcov(x,y); - assert(c, [-4.0 -4.0 -1.0 4.0 10.0 4.0 -1.0 -4.0 -4.0], 2*eps) - assert(l, [-4 -3 -2 -1 0 1 2 3 4]) +[inst/rssq.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/rssq.m +***** assert (rssq ([]), 0) +***** assert (rssq ([1 2 -1]), sqrt (6)) +***** assert (rssq ([1 2 -1]'), sqrt (6)) +***** assert (rssq ([1 2], 3), [1 2]) +***** error rssq () +***** error rssq (1, 2, 3) +***** error rssq (1, 1.5) +***** error rssq (1, -1) +8 tests, 8 passed, 0 known failure, 0 skipped +[inst/gauspuls.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/gauspuls.m +***** demo + fs = 11025; # arbitrary sample rate + f0 = 100; # pulse train sample rate + x = pulstran (0:1/fs:4/f0, 0:1/f0:4/f0, "gauspuls"); + plot ([0:length(x)-1]*1000/fs, x); + xlabel ("Time (ms)"); + ylabel ("Amplitude"); + title ("Gaussian pulse train at 10 ms intervals"); +***** assert (gauspuls ([]), []) +***** assert (gauspuls (zeros (10, 1)), ones (10, 1)) +***** assert (gauspuls (-1:1), [0, 1, 0]) +***** assert (gauspuls (0:1/100:0.3, 0.1), gauspuls ([0:1/100:0.3]', 0.1)') +***** error gauspuls () +***** error gauspuls (1, 2, 3, 4) +***** error gauspuls (1, -1) +***** error gauspuls (1, 2j) +***** error gauspuls (1, 1e3, 0) +9 tests, 9 passed, 0 known failure, 0 skipped +[inst/blackmanharris.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/blackmanharris.m +***** assert (blackmanharris (1), 1); +***** assert (blackmanharris (2), 0.00006 * ones (2, 1), eps); +***** assert (blackmanharris (15), flipud (blackmanharris (15)), 10*eps); +***** assert (blackmanharris (16), flipud (blackmanharris (16)), 10*eps); +***** assert (blackmanharris (15), blackmanharris (15, "symmetric")); +***** assert (blackmanharris (16)(1:15), blackmanharris (15, "periodic")); +***** error blackmanharris () +***** error blackmanharris (0.5) +***** error blackmanharris (-1) +***** error blackmanharris (ones (1, 4)) +***** error blackmanharris (1, 2) +***** error blackmanharris (1, "invalid") +12 tests, 12 passed, 0 known failure, 0 skipped +[inst/firpmord.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/firpmord.m +***** error firpmord ([1 2], [1 0], [1 1], [1 1]); +***** error firpmord ([0 2], [1 0], [1 1]); +***** error firpmord ([.1 1], [1 0], [1 1]); +***** error firpmord ([.1 .9], [1], [.1 .1]); +***** error firpmord ([.1 .2], [1 0], [.1 .1 .1]); +***** error firpmord ([.1 .2], [1 0], [1 0]); +***** assert ( + firpmord ([0.4 0.5], [0 1], [2.5e-4 2.5e-4]), + firpmord ([0.4 0.5], [0 1], [2.5e-4])) +***** test ds = 1e-4; dp = 0.01; assert ( + firpmord ([1 2 3 4 5 6 7 8]/10, [0 1 0 1 0], [ds dp ds dp ds]), + firpmord ([1 2 3 4 5 6 7 8]/10, [0 1 0 1 0], [ds dp])) +***** assert (1 + firpmord ([.1 .2], [0 1], [1e-4 .01], 1), 33) +***** assert (1 + firpmord ([ 15 20], [ 1 0], [ .1 .001], 100), 38) +***** assert (1 + firpmord ([ 8 10 ], [0 1 ], [.001 .1 ], 100), 91) +***** assert (1 + firpmord ([ 8 10 15 20], [0 1 0], [.001 .1 .001], 100), 90) #+1? +***** assert (1 + firpmord ([17 20 ], [1 0 ], [.01 1e-4 ], 100), 107)#-1? +***** assert (1 + firpmord ([ 22 25], [ 0 1], [ 1e-4 .01], 100), 107) +***** assert (1 + firpmord ([17 20 22 25], [1 0 1], [.01 1e-4 .01], 100), 107) +***** assert (1 + firpmord ([ 21 25], [ 1 0], [ .01 1e-4], 100), 81) #+1? +***** assert (1 + firpmord ([10 20 ], [0 1 ], [1e-4 .01 ], 100), 33) +***** assert (1 + firpmord ([10 20 21 25], [0 1 0], [1e-4 .01 1e-4], 100), 81) #+1? +***** assert (1 + firpmord ([20 25 ], [1 0 ], [.01 1e-4 ], 100), 65) #+1? +***** assert (1 + firpmord ([ 26 30], [ 0 1], [ 1e-4 .01], 100), 81) #+2? +***** assert (1 + firpmord ([20 25 26 30], [1 0 1], [.01 1e-4 .01], 100), 81) #+2? - y = 1; - [c, l] = xcov(x,y); - assert(c, [4.0 10.0 4.0], 2*eps) - assert(l, [-1 0 1]) -***** test - x = 1:5; - y = 1:5; - # maxlag - [c, l] = xcov(x,y, 2); - assert(c, [-1.0 4.0 10.0 4.0 -1.0], 2*eps) - assert(l, [-2 -1 0 1 2]) -***** test - x = 1:5; - y = 1:5; - # scale - [c, l] = xcov(x,y, 'none'); - assert(c, [-4.0 -4.0 -1.0 4.0 10.0 4.0 -1.0 -4.0 -4.0], 2*eps) - assert(l, [-4 -3 -2 -1 0 1 2 3 4]) +***** demo - [c, l] = xcov(x,y, 'biased'); - assert(c, [-0.8 -0.8 -0.2 0.8 2.0 0.8 -0.2 -0.8 -0.8], 2*eps) - assert(l, [-4 -3 -2 -1 0 1 2 3 4]) -5 tests, 5 passed, 0 known failure, 0 skipped + db2mag = @(x) 10^(x/20); + + fs = 8000; + [n f a w] = firpmord ([2500 3000], [1 0], [0.01 db2mag(-60)], fs); + b = firpm (n, f, a, w); + + [h f] = freqz (b, 1, 2^14); clf + plot (fs/2*f/pi, 20*log10 (abs (h))); grid on; axis ([0 fs/2 -90 5]) + ylabel ("Magnitude (dB)"); xlabel ("Frequency (Hz)") + title (sprintf ("Response analysis of firpmord / firpm low-pass filter design (order=%i)", length (b) - 1)) + axes ("position", [.24 .4 .4 .3]) + plot (fs/2*f/pi, abs (h)); grid on; axis ([0 2600 x=.987 2-x]) + ylabel ("Magnitude") + title ("Pass-band detail") + %-------------------------------------------------- + % Figure shows analysis of filter designed using + % firpm with firpmord; specs. are almost met. + +***** demo + + db2mag = @(x) 10^(x/20); + + b = firpm (firpmord ([0.3 0.4], [0 1], [db2mag(-80) .01], "c"){:}); + + [h f] = freqz (b, 1, 2^14); clf + plot (f/pi, 20*log10 (abs (h))); grid on; axis ([0 1 -110 5]) + ylabel ("Magnitude (dB)"); xlabel ("Frequency (normalized)") + title (sprintf ("Response analysis of firpmord / firpm high-pass filter design (order=%i)", length (b) - 1)) + axes ("position", [.52 .4 .35 .3]) + plot (f/pi, abs (h)); grid on; axis ([.39 1 x=.987 2-x]) + ylabel ("Magnitude") + title ("Pass-band detail") + %-------------------------------------------------- + % Figure shows analysis of filter designed using + % firpm with firpmord; specs. are exceeded. + +***** demo + + db2mag = @(x) 10^(x/20); + + ds = db2mag (-80); dp = 0.01; + b = firpm (firpmord ([1 2 3 4 5 6 7 8]/10, [0 1 0 1 0], [ds dp], "c"){:}); + + [h f] = freqz (b, 1, 2^14); clf + plot (f/pi, 20*log10 (abs (h))); grid on; axis ([0 1 -110 5]) + ylabel ("Magnitude (dB)"); xlabel ("Frequency (normalized)") + title ("Response analysis of firpmord / firpm multi-band-pass filter design") + title (sprintf ("Response analysis of firpmord / firpm multi-band-pass filter design (order=%i)", length (b) - 1)) + axes ("position", [.38 .5 .5 .2]) + plot (f/pi, abs (h)); grid on; axis ([.11 .79 x=.986 2-x]) + ylabel ("Magnitude") + title ("Pass-bands detail") + %-------------------------------------------------- + % Figure shows analysis of filter designed using + % firpm with firpmord; specs. are met. + +***** demo + + db2mag = @(x) 10^(x/20); + + ds = db2mag (-40); dp = 1 - db2mag (-0.1); + b = firpm (firpmord ([2 3 8 9]/32, [0 1 0], [ds dp], "c"){:}); + + [h f] = freqz (b, 1, 2^14); clf + plot (f/pi, 20*log10 (abs (h))); grid on; axis ([0 1 -50 3]) + ylabel ("Magnitude (dB)"); xlabel ("Frequency (normalized)") + title (sprintf ("Response analysis of firpmord / firpm band-pass filter design (order=%i)", length (b) - 1)) + axes ("position", [.45 .5 .4 .3]) + plot (f/pi, 20*log10 (abs (h))); grid on; axis ([.08 .26 x=-.13 -x]) + ylabel ("Magnitude (dB)") + title ("Pass-band detail") + %-------------------------------------------------- + % Figure shows analysis of filter designed using + % firpm with firpmord; specs. are not met. + +***** demo + + % FIRPMX: F, A, D, Fs are as firpmord. + % type in {0,1,2} constrains order to be {even,odd,either} resp. + + function h = firpmx (type, F, A, D, Fs = 2) + type *= !A(end); step = 2; bounds = [0 0]; + while (bounds(2) - bounds(1) != step) + if all (!bounds) [n f a w] = firpmord (F, A, D, Fs); + elseif (!bounds(1)) n = min (n - step, round (n * 0.994)); + elseif (!bounds(2)) n = max (n + step, round (n / 0.998)); + else n = fix (mean (bounds)); + endif + n += rem (n + rem (type, 2), step); + [b m] = firpm (n, f, a, w); + bounds(1 + (met = (abs(m) <= max (D)))) = n; + step -= bounds(2) - bounds(1) == type; + if (met) h = b; endif + endwhile + endfunction + + db2mag = @(x) 10^(x/20); + + ds = db2mag (-40); dp = 1 - db2mag (-0.1); + b = firpmx (2, [2 3 8 9]/32, [0 1 0], [ds dp]); + + [h f] = freqz (b, 1, 2^14); clf + plot (f/pi, 20*log10 (abs (h))); grid on; axis ([0 1 -50 3]) + ylabel ("Magnitude (dB)"); xlabel ("Frequency (normalized)") + title (sprintf ("Response analysis of firpmord / iterative-firpm band-pass filter design (order=%i)", length (b) - 1)) + axes ("position", [.45 .5 .4 .3]) + plot (f/pi, 20*log10 (abs (h))); grid on; axis ([.08 .26 x=-.13 -x]) + ylabel ("Magnitude (dB)") + title ("Pass-band detail") + %-------------------------------------------------- + % Figure shows analysis of filter designed iteratively + % using firpm with firpmord, so that specs. are met. +21 tests, 21 passed, 0 known failure, 0 skipped [inst/sos2tf.m] >>>>> /build/reproducible-path/octave-signal-1.4.5/inst/sos2tf.m ***** test @@ -7759,6 +9225,14 @@ assert (Bh, [1, 3, 3, 1] , 10*eps); assert (Ah, [1, 1.5 0.75 0.125], 10*eps); 12 tests, 12 passed, 0 known failure, 0 skipped +[inst/besself.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/besself.m +***** error [a, b] = besself () +***** error [a, b] = besself (1) +***** error [a, b] = besself (1, 2, 3, 4, 5) +***** error [a, b] = besself (.5, .2) +***** error [a, b] = besself (3, .2, "invalid") +5 tests, 5 passed, 0 known failure, 0 skipped [inst/filtord.m] >>>>> /build/reproducible-path/octave-signal-1.4.5/inst/filtord.m ***** demo @@ -7804,203 +9278,142 @@ n = filtord (sos); assert (n, 7, 1e-6) 12 tests, 12 passed, 0 known failure, 0 skipped -[inst/window.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/window.m -***** assert (window (@bartlett, 16), window ("bartlett", 16)) -***** assert (window (@hamming, 16), window ("hamming", 16)) -***** assert (window (@hanning, 16), window ("hanning", 16)) -***** assert (window (@triang, 16), window ("triang", 16)) -***** error window () -***** error window (1) -***** error window ("hanning") -7 tests, 7 passed, 0 known failure, 0 skipped -[inst/lpc.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/lpc.m -***** demo - noise = randn (10000, 1); - x = filter (1, [1 1/2 1/4 1/8], noise); - x = x(end-4096:end); - [a, g] = lpc (x, 3); - xe = filter ([0 -a(2:end)], 1, x); - e = x - xe; - [ac, k] = xcorr (e, "coeff"); - subplot (2,1,1); plot (x(1:100), "b-", xe(1:100), "r--"); - xlabel ("sample"); ylabel ("amplitude"); legend ("original","LPC estimate"); - subplot (2,1,2); plot (k,ac,"b-"); xlabel ("lag"); - title ("autocorrelation of prediction error"); -***** demo - if !isempty ( pkg ("list", "ltfat") ) - pkg load ltfat - [sig, fs] = linus; - x = sig(13628:14428); - [a, g] = lpc (x, 8); - F = round (sort (unique (abs (angle (roots (a))))) * fs / (2 * pi) ); - [h, w] = freqz (1, a, 512, "whole"); - subplot (2, 1, 1); - plot ( 1E3 * [0:1/fs:(length (x)-1)*1/fs], x); - xlabel ("time (ms)"); ylabel ("Amplitude"); - title ( "'linus' test signal" ); - subplot (2, 1, 2); - plot (w(1:256)/pi, 20*log10 (abs (h(1:256)))); - xlabel ("Normalized Frequency ({\\times \\pi} rad/sample)") - ylabel ("Magnitude (dB)") - txt = sprintf (['Signal sampling rate = %d kHz\nFormant frequencies: ' ... - '\nF1 = %d Hz\nF2 = %d Hz\nF3 = %d Hz\nF4 = %d Hz'], fs/1E3, ... - F(1), F(2), F(3), F(4)); - text (0.6, 20, txt); - endif - ## test input validation -***** error [a, g] = lpc () -***** error [a, g] = lpc (1) -***** error [a, g] = lpc (1, 1) -***** error [a, g] = lpc (1, 1, 1) -***** error [a, g] = lpc (1:10, 0) -***** error [a, g] = lpc (1:10, 10) -***** error [a, g] = lpc (1:10, 0.5) -***** error [a, g] = lpc (1:10, 1, [1 2]) +[inst/blackmannuttall.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/blackmannuttall.m +***** assert (blackmannuttall (1), 1) +***** assert (blackmannuttall (2), 0.0003628 * ones (2, 1), eps) +***** assert (blackmannuttall (15), flipud (blackmannuttall (15)), 10*eps); +***** assert (blackmannuttall (16), flipud (blackmannuttall (16)), 10*eps); +***** assert (blackmannuttall (15), blackmannuttall (15, "symmetric")); +***** assert (blackmannuttall (16)(1:15), blackmannuttall (15, "periodic")); +***** error blackmannuttall () +***** error blackmannuttall (0.5) +***** error blackmannuttall (-1) +***** error blackmannuttall (ones (1, 4)) +***** error blackmannuttall (1, 2) +***** error blackmannuttall (1, "invalid") +12 tests, 12 passed, 0 known failure, 0 skipped +[inst/fwht.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/fwht.m +***** assert (isempty (fwht ([]))); +***** assert (fwht (zeros (16)), zeros (16)); +***** assert (fwht (ones (16, 1)), [1; (zeros (15, 1))]); +***** assert (fwht (zeros (17, 1)), zeros (32, 1)); +***** assert (fwht ([1 -1 1 -1 1 -1 1 -1]), [0 0 0 0 0 0 0 1]); ***** test - x = [1:4 4:-1:1]; - [a, g] = lpc (x, 5); - assert (a, [1.0 -1.823903 1.101798 -0.405738 0.521153 -0.340032], 1e-6) - assert (g, 0.272194, 1e-6) -9 tests, 9 passed, 0 known failure, 0 skipped -[inst/xcorr.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/xcorr.m -***** shared x, y - x = 0.5.^(0:15); - y = circshift(x,5); -***** error xcorr () -***** error xcorr (1) -***** error xcorr (x, 1, x) -***** error xcorr (x, 'none', x) -***** error xcorr (x, x, 'invalid') -***** error xcorr (x, 'invalid') + x = randi (16, 16); + assert (ifwht (fwht (x)), x); ***** test - [c,lags] = xcorr(x); - # largest spike at 0 lag, where X matches itself - ie the center - [m, im] = max(c); - assert(m, 4/3, 1e-6) - assert(im, (numel(lags)+1)/2); - - [c1,lags1] = xcorr(x, x); - [m, im] = max(c1); - assert(m, 4/3, 1e-6) - assert(im, (numel(lags1)+1)/2); - assert(c1, c, 2*eps); - assert(lags1, lags); + x = randi (16, 16); + assert (ifwht (fwht (x, [], "sequency"), [], "sequency"), x); ***** test - [c,lags] = xcorr(x,y); - # largest spike at 0 lag, where X matches Y - [m, im] = max(c); - assert(m, 4/3, 1e-6) - assert(lags(im), -5); + x = randi (16, 16); + assert (ifwht (fwht (x, [], "hadamard"), [], "hadamard"), x); ***** test - [c0,lags0] = xcorr(x,y); - [c1,lags1] = xcorr(x,y, 'none'); - assert(c0, c1); - assert(lags0, lags1); + x = randi (16, 16); + assert (ifwht (fwht (x, [], "dyadic"), [], "dyadic"), x); +***** error fwht (); +***** error fwht (1, 2, 3, 4); +***** error fwht (0, 0); +***** error fwht (0, 5); +***** error fwht (0, [], "invalid"); +14 tests, 14 passed, 0 known failure, 0 skipped +[inst/zerocrossing.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/zerocrossing.m ***** test - [c0,lags0] = xcorr(x,y); - [c1,lags1] = xcorr(x,y, 'normalized'); - assert(lags0, lags1); - [m, im] = max(c1); - # at 0 lag, should be 1 - assert(m, 1, 1e-6); - [c2,lags2] = xcorr(x,y, 'coeff'); - assert(c1, c2); - assert(lags1, lags2); + x = linspace(0,1,100); + y = rand(1,100)-0.5; + x0= zerocrossing(x,y); + y0 = interp1(x,y,x0); + assert(norm(y0,inf), 0, 100*eps) ***** test - [c0,lags0] = xcorr(x,y); - [c1,lags1] = xcorr(x,y, 'biased'); - assert(lags0, lags1); - [m, im] = max(c1); - assert(m, 1/12, 1e-6); - - [c1,lags1] = xcorr(x, 'biased'); - assert(lags0, lags1); - [m, im] = max(c1); - assert(m, 1/12, 1e-6); + x = linspace(0,1,100); + y = rand(1,100)-0.5; + y(10:20) = 0; + x0= zerocrossing(x,y); + y0 = interp1(x,y,x0); + assert(norm(y0,inf), 0, 100*eps) +***** demo + x = linspace(0,1,100); + y = rand(1,100)-0.5; + x0= zerocrossing(x,y); + y0 = interp1(x,y,x0); + plot(x,y,x0,y0,'x') +***** demo + x = linspace(0,1,100); + y = rand(1,100)-0.5; + y(10:20) = 0; + x0= zerocrossing(x,y); + y0 = interp1(x,y,x0); + plot(x,y,x0,y0,'x') +2 tests, 2 passed, 0 known failure, 0 skipped +[inst/ismaxphase.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/ismaxphase.m +***** demo + [b, a] = butter (1, .5); + f = ismaxphase (b, a) +***** error n = ismaxphase () +***** error n = ismaxphase (1, 1, 1, 1) +***** error n = ismaxphase (1, 1, 1, 1, 1) +***** error n = ismaxphase ([1:10]', 1) +***** error n = ismaxphase (1, [1:10]') +***** error n = ismaxphase ([1:10]', [1:10]') +***** error n = ismaxphase (1:10, 1:10, 1:10) +***** error n = ismaxphase (ones (3), ones (3)) ***** test - [c0,lags0] = xcorr(x,y); - [c1,lags1] = xcorr(x,y, 'unbiased'); - assert(lags0, lags1); - [m, im] = max(c1); - assert(m, 1/8.25, 1e-6); + z1 = [0.9*exp(j*0.6*pi), 0.9*exp(-j*0.6*pi)]; + z2 = [0.8*exp(j*0.8*pi), 0.8*exp(-j*0.8*pi)]; + b = poly ([z1 z2]); + a = 1; + f = ismaxphase (b, a); + assert (f, false) ***** test - [c,lags] = xcorr(x,y, 10); - [m, im] = max(c); - assert(lags(im), -5); - assert(lags(1), -10); - assert(lags(end), 10); - - [c,lags] = xcorr(x,10); - [m, im] = max(c); - assert(lags(1), -10); - assert(lags(end), 10); + z1 = [0.9*exp(j*0.6*pi), 0.9*exp(-j*0.6*pi)]; + z2 = [0.8*exp(j*0.8*pi), 0.8*exp(-j*0.8*pi)]; + b = poly ([1./z1 1./z2]); + a = 1; + f = ismaxphase (b, a); + assert (f, true) ***** test - [c0,lags0] = xcorr(x,y, 'normalized', 10); - [c1,lags1] = xcorr(x,y, 10, 'normalized'); - assert(c0, c1); - assert(lags0, lags1); + z1 = [0.9*exp(j*0.6*pi), 0.9*exp(-j*0.6*pi)]; + z2 = [0.8*exp(j*0.8*pi), 0.8*exp(-j*0.8*pi)]; + b = poly ([z1 1./z2]); + a = 1; + f = ismaxphase (b, a); + assert (f, false) +***** test + z1 = [0.9*exp(j*0.6*pi), 0.9*exp(-j*0.6*pi)]; + z2 = [0.8*exp(j*0.8*pi), 0.8*exp(-j*0.8*pi)]; + b = poly ([1./z1 z2]); + a = 1; + f = ismaxphase (b, a); + assert (f, false) +***** test + [b, a] = butter (1, .5); + f = ismaxphase (b, a); + assert (f, false) +***** test + [b, a] = butter (8, .5); + f = ismaxphase (b, a); + assert (f, false) 14 tests, 14 passed, 0 known failure, 0 skipped -[inst/pulstran.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/pulstran.m -***** error pulstran -***** error pulstran(1,2,3,4,5,6) -***** ## parameter size and shape checking -***** shared t,d - t = 0:0.01:1; d=0:0.1:1; -***** assert (isempty(pulstran([], d, 'sin'))); -***** assert (pulstran(t, [], 'sin'), zeros(size(t))); -***** assert (isempty(pulstran([], d, boxcar(5)))); -***** assert (pulstran(t, [], boxcar(5)), zeros(size(t))); -***** assert (size(pulstran(t,d,'sin')), size(t)); -***** assert (size(pulstran(t,d','sin')), size(t)); -***** assert (size(pulstran(t',d,'sin')), size(t')); -***** assert (size(pulstran(t,d','sin')), size(t)); -***** demo - fs = 11025; # arbitrary sample rate - f0 = 100; # pulse train sample rate - w = 0.003; # pulse width of 3 milliseconds - t = 0:1/fs:0.1; d=0:1/f0:0.1; # define sample times and pulse times - a = hanning(length(d)); # define pulse amplitudes - - subplot(221); - x = pulstran(t', d', 'rectpuls', w); - plot([0:length(x)-1]*1000/fs, x); - hold on; plot(d*1000,ones(size(d)),'g*;pulse;'); hold off; - ylabel("amplitude"); xlabel("time (ms)"); - title("rectpuls"); - - subplot(223); - x = pulstran(f0*t, [f0*d', a], 'sinc'); - plot([0:length(x)-1]*1000/fs, x); - hold on; plot(d*1000,a,'g*;pulse;'); hold off; - ylabel("amplitude"); xlabel("time (ms)"); - title("sinc => band limited interpolation"); - - subplot(222); - pulse = boxcar(30); # pulse width of 3 ms at 10 kHz - x = pulstran(t, d', pulse, 10000); - plot([0:length(x)-1]*1000/fs, x); - hold on; plot(d*1000,ones(size(d)),'g*;pulse;'); hold off; - ylabel("amplitude"); xlabel("time (ms)"); - title("interpolated boxcar"); - - subplot(224); - pulse = sin(2*pi*[0:0.0001:w]/w).*[w:-0.0001:0]; - x = pulstran(t', [d', a], pulse', 10000); - plot([0:length(x)-1]*1000/fs, x); - hold on; plot(d*1000,a*w,'g*;pulse;'); hold off; title(""); - ylabel("amplitude"); xlabel("time (ms)"); - title("interpolated asymmetric sin"); - - %---------------------------------------------------------- - % Should see (1) rectangular pulses centered on *, - % (2) rectangular pulses to the right of *, - % (3) smooth interpolation between the *'s, and - % (4) asymmetric sines to the right of * -10 tests, 10 passed, 0 known failure, 0 skipped +[inst/pow2db.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/pow2db.m +***** shared pow + pow = [0, 10, 20, 60, 100]; +***** assert (pow2db (pow), [-Inf, 10.000, 13.010, 17.782, 20.000], 0.01) +***** assert (pow2db (pow'), [-Inf; 10.000; 13.010; 17.782; 20.000], 0.01) +***** error pow2db () +***** error pow2db (1, 2) +***** error pow2db (-5) +***** error pow2db ([-5 7]) +6 tests, 6 passed, 0 known failure, 0 skipped +[inst/idst.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/idst.m +***** test + x = log(gausswin(32)); + assert(x, idst(dst(x)), 100*eps) +1 test, 1 passed, 0 known failure, 0 skipped [inst/rectpuls.m] >>>>> /build/reproducible-path/octave-signal-1.4.5/inst/rectpuls.m ***** demo @@ -8022,259 +9435,53 @@ ***** error rectpuls (1, 2, 3) ***** error rectpuls (1, 2j) 9 tests, 9 passed, 0 known failure, 0 skipped -[inst/filtfilt.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/filtfilt.m -***** error filtfilt (); -***** error filtfilt (1, 2, 3, 4); -***** error filtfilt ([0.28, 0.71, 0.28], 1, rand ()) -***** error filtfilt ([0.28, 0.71, 0.28], 1, rand (6, 1)) -***** test - randn('state',0); - r = randn(1,200); - [b,a] = butter(10, [.2, .25]); - yfb = filtfilt(b, a, r); - assert (size(r), size(yfb)); - assert (mean(abs(yfb)) < 1e3); - assert (mean(abs(yfb)) < mean(abs(r))); - ybf = fliplr(filtfilt(b, a, fliplr(r))); - assert (mean(abs(ybf)) < 1e3); - assert (mean(abs(ybf)) < mean(abs(r))); -***** test - randn('state',0); - r = randn(1,1000); - s = 10 * sin(pi * 4e-2 * (1:length(r))); - [b,a] = cheby1(2, .5, [4e-4 8e-2]); - y = filtfilt(b, a, r+s); - assert (size(r), size(y)); - assert (mean(abs(y)) < 1e3); - assert (corr(s(250:750)(:), y(250:750)(:)) > .95) - [b,a] = butter(2, [4e-4 8e-2]); - yb = filtfilt(b, a, r+s); - assert (mean(abs(yb)) < 1e3); - assert (corr(y(:), yb(:)) > .99) +[inst/cconv.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cconv.m +***** shared x + x = [1, 2, 3, 4, 5]; +***** assert (cconv (x, 1), [1, 2, 3, 4, 5], 2*eps) +***** assert (cconv (x', 1), [1; 2; 3; 4; 5], 2*eps) +***** assert (real (cconv (x, [1 1])), [1, 3, 5, 7, 9, 5], 2*eps) +***** assert (cconv (x, [1 1], 3), [8, 12, 10]) +***** assert (cconv ([2 1 2 1], [1 2 3 4]), [2 5 10 16 12 11 4], 1e-14) +***** assert (cconv ([2 1 2 1], [1 2 3 4], 4), [14 16 14 16]) +***** assert (cconv ([2 1 2 1], [1 2 3 4], 3), [22 17 21]) +***** assert (cconv ([2 1 2 1], [1 2 3 4], 2), [28 32]) +***** assert (cconv ([2 1 2 1], [1 2 3 4], 1), 60) +***** assert (cconv (x*j, 1), [1j, 2j, 3j, 4j, 5j]) +***** assert (cconv (x'*j, 1), [1j; 2j; 3j; 4j; 5j]) +***** error cconv () +***** error cconv (1) +***** error cconv (1, 1, [1 1]) +***** error cconv (ones (2, 2), 1) +***** error cconv (1, ones (2, 2)) +***** error cconv (1, 1, 3.5) +17 tests, 17 passed, 0 known failure, 0 skipped +[inst/czt.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/czt.m +***** shared x + x = [1,2,4,1,2,3,5,2,3,5,6,7,8,4,3,6,3,2,5,1]; +***** assert(fft(x),czt(x),10000*eps); +***** assert(fft(x'),czt(x'),10000*eps); +***** assert(fft([x',x']),czt([x',x']),10000*eps); +3 tests, 3 passed, 0 known failure, 0 skipped +[inst/cceps.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cceps.m ***** test - randn('state',0); - r = randn(1,1000); - s = 10 * sin(pi * 4e-2 * (1:length(r))); - [b,a] = butter(2, [4e-4 8e-2]); - y = filtfilt(b, a, [r.' s.']); - yr = filtfilt(b, a, r); - ys = filtfilt(b, a, s); - assert (y, [yr.' ys.']); - y2 = filtfilt(b.', a.', [r.' s.']); - assert (y, y2); -7 tests, 7 passed, 0 known failure, 0 skipped -[inst/vco.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/vco.m -***** error vco -***** error vco([1 2]) + x = randn (256, 1); + c = cceps (x); + assert (size (c), size (x)) +***** error cceps () +***** error cceps (1, 2, 3) +***** error cceps (ones (4)) +***** error cceps (0) +***** error cceps (zeros (10, 1)) +6 tests, 6 passed, 0 known failure, 0 skipped +[inst/convmtx.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/convmtx.m +***** assert(convmtx([3,4,5],3),[3,4,5,0,0;0,3,4,5,0;0,0,3,4,5]) +***** assert(convmtx([3;4;5],3),[3,0,0;4,3,0;5,4,3;0,5,4;0,0,5]) 2 tests, 2 passed, 0 known failure, 0 skipped -[inst/zp2sos.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/zp2sos.m -***** test - B=[1 0 0 0 0 1]; A=[1 0 0 0 0 .9]; - [z,p,k] = tf2zp(B,A); - [sos,g] = zp2sos(z,p,k); - [Bh,Ah] = sos2tf(sos,g); - assert({Bh,Ah},{B,A},100*eps); -***** test - sos = zp2sos ([]); - assert (sos, [1, 0, 0, 1, 0, 0], 100*eps); -***** test - sos = zp2sos ([], []); - assert (sos, [1, 0, 0, 1, 0, 0], 100*eps); -***** test - sos = zp2sos ([], [], 2); - assert (sos, [2, 0, 0, 1, 0, 0], 100*eps); -***** test - [sos, g] = zp2sos ([], [], 2); - assert (sos, [1, 0, 0, 1, 0, 0], 100*eps); - assert (g, 2, 100*eps); -***** test - sos = zp2sos([], [0], 1); - assert (sos, [0, 1, 0, 1, 0, 0], 100*eps); -***** test - sos = zp2sos([0], [], 1); - assert (sos, [1, 0, 0, 0, 1, 0], 100*eps); -***** test - sos = zp2sos([-1-j -1+j], [-1-2j -1+2j], 10); - assert (sos, [10, 20, 20, 1, 2, 5], 100*eps); -8 tests, 8 passed, 0 known failure, 0 skipped -[inst/phasez.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/phasez.m -***** demo - N = 2; - b = ones (1, N)/N; - a = 1; - [phi, w] = phasez (b, a) - ## test input validation -***** error n = phasez () -***** error n = phasez (1, 1, 1, 1, 1) -***** error n = phasez (1:10, 1:10, 1:10) -***** error n = phasez (ones (3), ones (3)) -***** test - % moving average - N = 2; - b = ones (1, N)/N; - a = 1; - [phi, w] = phasez (b, a); - PHI = -w * (N-1) /2; - assert (phi, PHI, eps^(3/5)) -***** test - % moving average - N = 5; - b = ones (1, N)/N; - a = 1; - [phi, w] = phasez (b, a); - PHI = -w * (N-1) /2; - assert (phi, PHI, eps^(3/5)) -***** test - % Oppenheim - Example 5.6 - 2nd-Order IIR System - % - % 1 - % H(z) = --------------------------- - % 1 − 2r cos θz^−1 + r^2 z^−2 - % - % ang(H(e^jω)) = − arctan[ r sin(ω − θ) / (1 − r cos(ω − θ)) ] − arctan[ r sin(ω + θ) / (1 − r cos(ω + θ)) ] - % - r = 0.5; theta = pi/4; - b = 1; - a = [ 1 -2*r*cos(theta) r^2]; - [phi, w] = phasez (b, a); - PHI = - atan ( r*sin (w - theta) ./ (1 - r*cos (w - theta)) ) - atan ( r*sin (w + theta) ./ (1 - r*cos (w+theta)) ); - assert (phi, PHI, eps^(3/5)) -7 tests, 7 passed, 0 known failure, 0 skipped -[inst/cplxreal.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cplxreal.m -***** test - [zc, zr] = cplxreal ([]); - assert (isempty (zc)) - assert (isempty (zr)) -***** test - [zc, zr] = cplxreal (1); - assert (isempty (zc)) - assert (zr, 1) -***** test - [zc, zr] = cplxreal ([1+1i, 1-1i]); - assert (zc, 1+1i) - assert (isempty (zr)) -***** test - [zc, zr] = cplxreal (roots ([1, 0, 0, 1])); - assert (zc, complex (0.5, sin (pi/3)), 10*eps) - assert (zr, -1, 2*eps) -***** test - [zc, zr] = cplxreal (roots ([1, 0, 0, 1, 0])); - assert (zc, complex (0.5, sin (pi/3)), 10*eps) - assert (zr, [-1; 0], 2*eps) -***** test - [zc, zr] = cplxreal (roots ([1, 0, 0, 1, 0, 0])); - assert (zc, complex (0.5, sin (pi/3)), 10*eps) - assert (zr, [-1; 0; 0], 2*eps) -***** error cplxreal () -***** error cplxreal (1, 2, 3, 4) -***** error cplxreal (1, ones (2, 3)) -***** error cplxreal (1, -1) -***** error cplxreal (1, [], 3) -11 tests, 11 passed, 0 known failure, 0 skipped -[inst/fir2.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/fir2.m -***** xtest - f = [0 0.6 0.6 1]; m = [1 1 0 0]; - b9 = fir2 (30, f, m, 9); - b16 = fir2 (30, f, m, 16); - b17 = fir2 (30, f, m, 17); - b32 = fir2 (30, f, m, 32); - assert ( isequal (b9, b16)) - assert ( isequal (b17, b32)) - assert (~isequal (b16, b17)) -***** test - f = [0, 0.7, 0.7, 1]; m = [0, 0, 1, 1]; - b = fir2 (50, f, m); - h = abs (freqz (b, 1, [0, 0.7, 1], 2)); - assert (h(1) <= 3e-3) - assert (h(2) <= 1/sqrt (2)) - assert (h(3), 1, 2e-3) -***** test - f = [0, 0.25, 0.25, 0.75, 0.75, 1]; m = [0, 0, 1, 1, 0, 0]; - b = fir2 (50, f, m); - h = abs (freqz (b, 1, [0, 0.25, 0.5, 0.75, 1], 2)); - assert (h(1) <= 3e-3) - assert (h(2) <= 1/sqrt (2)) - assert (h(3), 1, 2e-3) - assert (h(4) <= 1/sqrt (2)) - assert (h(5) <= 3e-3) -***** test - f = [0, 0.45, 0.45, 0.55, 0.55, 1]; m = [1, 1, 0, 0, 1, 1]; - b = fir2 (50, f, m); - h = abs (freqz (b, 1, [0, 0.45, 0.5, 0.55, 1], 2)); - assert (h(1), 1, 2e-3) - assert (h(2) <= 1/sqrt (2)) - assert (h(3) <= 1e-1) - assert (h(4) <= 1/sqrt (2)) - assert (h(5), 1, 2e-3) -***** test #bug 59066 - f = [0, 0.45, 0.45, 0.55, 0.55, 1]; m = [1, 1, 0, 0, 1, 1]; - b = fir2 (int32(50), f, m); - assert(numel(b), 51) - - fail ("fir2 (50.1, f, m)", "fir2: n must be a non negative integer") - fail ("fir2 (-1, f, m)", "fir2: n must be a non negative integer") -***** demo - f=[0, 0.3, 0.3, 0.6, 0.6, 1]; m=[0, 0, 1, 1/2, 0, 0]; - [h, w] = freqz(fir2(100,f,m)); - subplot(121); - plot(f,m,';target response;',w/pi,abs(h),';filter response;'); - subplot(122); - plot(f,20*log10(m+1e-5),';target response (dB);',... - w/pi,20*log10(abs(h)),';filter response (dB);'); -***** demo - f=[0, 0.3, 0.3, 0.6, 0.6, 1]; m=[0, 0, 1, 1/2, 0, 0]; - plot(f,20*log10(m+1e-5),';target response;'); - hold on; - [h, w] = freqz(fir2(50,f,m,512,0)); - plot(w/pi,20*log10(abs(h)),';filter response (ramp=0);'); - [h, w] = freqz(fir2(50,f,m,512,25.6)); - plot(w/pi,20*log10(abs(h)),';filter response (ramp=pi/20 rad);'); - [h, w] = freqz(fir2(50,f,m,512,51.2)); - plot(w/pi,20*log10(abs(h)),';filter response (ramp=pi/10 rad);'); - hold off; -***** demo - % Classical Jakes spectrum - % X represents the normalized frequency from 0 - % to the maximum Doppler frequency - asymptote = 2/3; - X = linspace(0,asymptote-0.0001,200); - Y = (1 - (X./asymptote).^2).^(-1/4); - - % The target frequency response is 0 after the asymptote - X = [X, asymptote, 1]; - Y = [Y, 0, 0]; - - plot(X,Y,'b;Target spectrum;'); - hold on; - [H,F]=freqz(fir2(20, X, Y)); - plot(F/pi,abs(H),'c;Synthesized spectrum (n=20);'); - [H,F]=freqz(fir2(50, X, Y)); - plot(F/pi,abs(H),'r;Synthesized spectrum (n=50);'); - [H,F]=freqz(fir2(200, X, Y)); - plot(F/pi,abs(H),'g;Synthesized spectrum (n=200);'); - hold off; - title('Theoretical/Synthesized CLASS spectrum'); - xlabel('Normalized frequency (Fs=2)'); - ylabel('Magnitude'); -5 tests, 5 passed, 0 known failure, 0 skipped -[inst/peak2rms.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/peak2rms.m -***** assert (peak2rms (1), 1) -***** assert (peak2rms (-5), 1) -***** assert (peak2rms ([-2 3; 4 -2]), [4/sqrt(10), 3/sqrt((9+4)/2)]) -***** assert (peak2rms ([-2 3; 4 -2], 2), [3/sqrt((9+4)/2); 4/sqrt(10)]) -***** assert (peak2rms ([1 2 3], 3), [1 1 1]) -***** error peak2rms () -***** error peak2rms (1, 2, 3) -***** error peak2rms (1, 1.5) -***** error peak2rms (1, -1) -9 tests, 9 passed, 0 known failure, 0 skipped [inst/primitive.m] >>>>> /build/reproducible-path/octave-signal-1.4.5/inst/primitive.m ***** demo @@ -8290,8 +9497,29 @@ ***** error primitive (1) ***** error primitive (1, 2, 3, 4) 3 tests, 3 passed, 0 known failure, 0 skipped -[inst/cheb2ord.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cheb2ord.m +[inst/hann.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/hann.m +***** assert (hann (1), 1); +***** assert (hann (2), zeros (2, 1)); +***** assert (hann (16), flipud (hann (16)), 10*eps); +***** assert (hann (15), flipud (hann (15)), 10*eps); +***** test + N = 15; + A = hann (N); + assert (A(ceil (N/2)), 1); +***** assert (hann (15), hann (15, "symmetric")); +***** assert (hann (16)(1:15), hann (15, "periodic")); +***** test + N = 16; + A = hann (N, "periodic"); + assert (A (N/2 + 1), 1); +***** error hann () +***** error hann (0.5) +***** error hann (-1) +***** error hann (1, "invalid") +12 tests, 12 passed, 0 known failure, 0 skipped +[inst/cheb1ord.m] +>>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cheb1ord.m ***** demo fs = 44100; fpass = 4000; @@ -8300,14 +9528,14 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby2 (n, Rstop, Wn_p); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby1 (n, Rpass, Wn_p); SYS = tf (b, a, 1 / fs); f = (0:fs/2)'; W = f * (2 * pi / fs); [H, P] = bode (SYS, 2 * pi * f); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev low-pass Typ II : matching pass band"); + title ("Digital Chebyshev low-pass Typ I : matching pass band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8327,14 +9555,14 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby2 (n, Rstop, Wn_s); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby1 (n, Rpass, Wn_s); SYS = tf (b, a, 1 / fs); f = (0:fs/2)'; W = f * (2 * pi / fs); [H, P] = bode (SYS, 2 * pi * f); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev low-pass Typ II : matching stop band"); + title ("Digital Chebyshev low-pass Typ I : matching stop band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8354,13 +9582,13 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby2 (n, Rstop, Wn_p, "high"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby1 (n, Rpass, Wn_p, "high"); f = (0:fs/2)'; W = f * (2 * pi / fs); H = freqz (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev high-pass Typ II : matching pass band"); + title ("Digital Chebyshev high-pass Typ I : matching pass band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8380,13 +9608,13 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby2 (n, Rstop, Wn_s, "high"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby1 (n, Rpass, Wn_s, "high"); f = (0:fs/2)'; W = f * (2 * pi / fs); H = freqz (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev high-pass Typ II : matching stop band"); + title ("Digital Chebyshev high-pass Typ I : matching stop band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8406,13 +9634,13 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby2 (n, Rstop, Wn_p); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby1 (n, Rpass, Wn_p); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev band-pass Typ II : matching pass band, limit on upper freq"); + title ("Digital Chebyshev band-pass Typ I : matching pass band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8435,13 +9663,13 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby2 (n, Rstop, Wn_s); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby1 (n, Rpass, Wn_s); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev band-pass Typ II : matching stop band, limit on upper freq"); + title ("Digital Chebyshev band-pass Typ I : matching stop band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8464,13 +9692,13 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby2 (n, Rstop, Wn_p); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby1 (n, Rpass, Wn_p); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev band-pass Typ II : matching pass band, limit on lower freq"); + title ("Digital Chebyshev band-pass Typ I : matching pass band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8493,13 +9721,13 @@ Rstop = 26; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby2 (n, Rstop, Wn_s); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby1 (n, Rpass, Wn_s); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev band-pass Typ II : matching stop band, limit on lower freq"); + title ("Digital Chebyshev band-pass Typ I : matching stop band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8522,14 +9750,14 @@ Rstop = 40; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby2 (n, Rstop, Wn_p, "stop"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby1 (n, Rpass, Wn_p, "stop"); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); Ampl = abs (H); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev notch Typ II : matching pass band, limit on upper freq"); + title ("Digital Chebyshev notch Typ I : matching pass band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8553,14 +9781,14 @@ Rstop = 40; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby2 (n, Rstop, Wn_s, "stop"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby1 (n, Rpass, Wn_s, "stop"); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); Ampl = abs (H); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev notch Typ II : matching stop band, limit on upper freq"); + title ("Digital Chebyshev notch Typ I : matching stop band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8584,14 +9812,14 @@ Rstop = 40; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby2 (n, Rstop, Wn_p, "stop"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby1 (n, Rpass, Wn_p, "stop"); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); Ampl = abs (H); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev notch Typ II : matching pass band, limit on lower freq"); + title ("Digital Chebyshev notch Typ I : matching pass band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8615,14 +9843,14 @@ Rstop = 40; Wpass = 2 / fs * fpass; Wstop = 2 / fs * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop) - [b, a] = cheby2 (n, Rstop, Wn_s, "stop"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop) + [b, a] = cheby1 (n, Rpass, Wn_s, "stop"); f = (6000:14000)'; W = f * (2 * pi / fs); H = freqz (b, a, W); Ampl = abs (H); plot (f, 20 * log10 (abs (H))); - title ("Digital Chebyshev notch Typ II : matching stop band, limit on lower freq"); + title ("Digital Chebyshev notch Typ I : matching stop band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8645,13 +9873,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby2 (n, Rstop, Wn_p, "s"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby1 (n, Rpass, Wn_p, "s"); f = 1000:10:100000; W = 2 * pi * f; H = freqs (b, a, W); semilogx (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev low-pass Typ II : matching pass band"); + title ("Analog Chebyshev low-pass Typ I : matching pass band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8670,13 +9898,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby2 (n, Rstop, Wn_s, "s"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby1 (n, Rpass, Wn_s, "s"); f = 1000:10:100000; W = 2 * pi * f; H = freqs (b, a, W); semilogx (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev low-pass Typ II : matching stop band"); + title ("Analog Chebyshev low-pass Typ I : matching stop band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8695,13 +9923,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby2 (n, Rstop, Wn_p, "high", "s"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby1 (n, Rpass, Wn_p, "high", "s"); f = 1000:10:100000; W = 2 * pi * f; H = freqs (b, a, W); semilogx (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev high-pass Typ II : matching pass band"); + title ("Analog Chebyshev high-pass Typ I : matching pass band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8720,13 +9948,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby2 (n, Rstop, Wn_s, "high", "s"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby1 (n, Rpass, Wn_s, "high", "s"); f = 1000:10:100000; W = 2 * pi * f; H = freqs (b, a, W); semilogx (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev high-pass Typ II : matching stop band"); + title ("Analog Chebyshev high-pass Typ I : matching stop band"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8745,13 +9973,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby2 (n, Rstop, Wn_p, "s"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby1 (n, Rpass, Wn_p, "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev band-pass Typ II : matching pass band, limit on upper freq"); + title ("Analog Chebyshev band-pass Typ I : matching pass band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8773,13 +10001,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby2 (n, Rstop, Wn_s, "s"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby1 (n, Rpass, Wn_s, "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev band-pass Typ II : matching stop band, limit on upper freq"); + title ("Analog Chebyshev band-pass Typ I : matching stop band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8801,13 +10029,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby2 (n, Rstop, Wn_p, "s"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby1 (n, Rpass, Wn_p, "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev band-pass Typ II : matching pass band, limit on lower freq"); + title ("Analog Chebyshev band-pass Typ I : matching pass band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8829,13 +10057,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby2 (n, Rstop, Wn_s, "s"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby1 (n, Rpass, Wn_s, "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev band-pass Typ II : matching stop band, limit on lower freq"); + title ("Analog Chebyshev band-pass Typ I : matching stop band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8857,13 +10085,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby2 (n, Rstop, Wn_p, "stop", "s"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby1 (n, Rpass, Wn_p, "stop", "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev notch Typ II : matching pass band, limit on upper freq"); + title ("Analog Chebyshev notch Typ I : matching pass band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8886,13 +10114,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby2 (n, Rstop, Wn_s, "stop", "s"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby1 (n, Rpass, Wn_s, "stop", "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev notch Typ II : matching stop band, limit on upper freq"); + title ("Analog Chebyshev notch Typ I : matching stop band, limit on upper freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8915,13 +10143,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby2 (n, Rstop, Wn_p, "stop", "s"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby1 (n, Rpass, Wn_p, "stop", "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev notch Typ II : matching pass band, limit on lower freq"); + title ("Analog Chebyshev notch Typ I : matching pass band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8944,13 +10172,13 @@ Rstop = 26; Wpass = 2 * pi * fpass; Wstop = 2 * pi * fstop; - [n, Wn_p, Wn_s] = cheb2ord (Wpass, Wstop, Rpass, Rstop, "s") - [b, a] = cheby2 (n, Rstop, Wn_s, "stop", "s"); + [n, Wn_p, Wn_s] = cheb1ord (Wpass, Wstop, Rpass, Rstop, "s") + [b, a] = cheby1 (n, Rpass, Wn_s, "stop", "s"); f = 6000:14000; W = 2 * pi * f; H = freqs (b, a, W); plot (f, 20 * log10 (abs (H))); - title ("Analog Chebyshev notch Typ II : matching stop band, limit on lower freq"); + title ("Analog Chebyshev notch Typ I : matching stop band, limit on lower freq"); xlabel ("Frequency (Hz)"); ylabel ("Attenuation (dB)"); grid on; @@ -8968,1326 +10196,148 @@ ylim ([-80, 0]); ***** test # Analog band-pass - [n, Wn_p, Wn_s] = cheb2ord (2 * pi * [9875, 10126.5823], ... + [n, Wn_p, Wn_s] = cheb1ord (2 * pi * [9875, 10126.5823], ... 2 * pi * [9000, 10437], 1, 26, "s"); assert (n, 3); - assert (round (Wn_p), [61074, 64640]); - assert (round (Wn_s), [60201, 65578]); + assert (round (Wn_p), [62046, 63627]); + assert (round (Wn_s), [61652, 64035]); ***** test # Analog band-pass - [n, Wn_p, Wn_s] = cheb2ord (2 * pi * [9875, 10126.5823], ... + [n, Wn_p, Wn_s] = cheb1ord (2 * pi * [9875, 10126.5823], ... 2 * pi * [9581 12000], 1, 26, "s"); assert (n, 3); - assert (round (Wn_p), [61074, 64640]); - assert (round (Wn_s), [60199, 65580]); + assert (round (Wn_p), [62046, 63627]); + assert (round (Wn_s), [61651, 64036]); ***** test # Analog high-pass - [n, Wn_p, Wn_s] = cheb2ord (2 * pi * 13584, 2 * pi * 4000, 1, 26, "s"); + [n, Wn_p, Wn_s] = cheb1ord (2 * pi * 13584, 2 * pi * 4000, 1, 26, "s"); assert (n, 3); - assert (round (Wn_p), 37832); - assert (round (Wn_s), 25133); + assert (round (Wn_p), 85351); + assert (round (Wn_s), 56700); ***** test # Analog low-pass - [n, Wn_p, Wn_s] = cheb2ord (2 * pi * 4000, 2 * pi * 13584, 1, 26, "s"); + [n, Wn_p, Wn_s] = cheb1ord (2 * pi * 4000, 2 * pi * 13584, 1, 26, "s"); assert (n, 3); - assert (round (Wn_p), 56700); - assert (round (Wn_s), 85351); + assert (round (Wn_p), 25133); + assert (round (Wn_s), 37832); ***** test # Analog notch (narrow band-stop) - [n, Wn_p, Wn_s] = cheb2ord (2 * pi * [9000, 10437], ... + [n, Wn_p, Wn_s] = cheb1ord (2 * pi * [9000, 10437], ... 2 * pi * [9875, 10126.5823], 1, 26, "s"); assert (n, 3); - assert (round (Wn_p), [61652, 64035]); - assert (round (Wn_s), [62046, 63627]); + assert (round (Wn_p), [60201, 65578]); + assert (round (Wn_s), [61074, 64640]); ***** test # Analog notch (narrow band-stop) - [n, Wn_p, Wn_s] = cheb2ord (2 * pi * [9581, 12000], ... + [n, Wn_p, Wn_s] = cheb1ord (2 * pi * [9581, 12000], ... 2 * pi * [9875, 10126.5823], 1, 26, "s"); assert (n, 3); - assert (round (Wn_p), [61651, 64036]); - assert (round (Wn_s), [62046, 63627]); + assert (round (Wn_p), [60199, 65580]); + assert (round (Wn_s), [61074, 64640]); ***** test # Digital band-pass fs = 44100; - [n, Wn_p, Wn_s] = cheb2ord (2 / fs * [9500, 9750], ... + [n, Wn_p, Wn_s] = cheb1ord (2 / fs * [9500, 9750], ... 2 / fs * [8500, 10052], 1, 26); Wn_p = Wn_p * fs / 2; Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn_p), [9344, 9908]); - assert (round (Wn_s), [9203, 10052]); + assert (round (Wn_p), [9500, 9750]); + assert (round (Wn_s), [9437, 9814]); ***** test # Digital band-pass fs = 44100; - [n, Wn_p, Wn_s] = cheb2ord (2 / fs * [9500, 9750], ... + [n, Wn_p, Wn_s] = cheb1ord (2 / fs * [9500, 9750], ... 2 / fs * [9182, 12000], 1, 26); Wn_p = Wn_p * fs / 2; Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn_p), [9344, 9908]); - assert (round (Wn_s), [9182, 10073]); + assert (round (Wn_p), [9500, 9750]); + assert (round (Wn_s), [9428, 9823]); ***** test # Digital high-pass fs = 44100; - [n, Wn_p, Wn_s] = cheb2ord (2 / fs * 10988, 2 / fs * 4000, 1, 26); + [n, Wn_p, Wn_s] = cheb1ord (2 / fs * 10988, 2 / fs * 4000, 1, 26); Wn_p = Wn_p * fs / 2; Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn_p), 5829); - assert (round (Wn_s), 4000); + assert (round (Wn_p), 10988); + assert (round (Wn_s), 8197); ***** test # Digital low-pass fs = 44100; - [n, Wn_p, Wn_s] = cheb2ord (2 / fs * 4000, 2 / fs * 10988, 1, 26); + [n, Wn_p, Wn_s] = cheb1ord (2 / fs * 4000, 2 / fs * 10988, 1, 26); Wn_p = Wn_p * fs / 2; Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn_p), 8197); - assert (round (Wn_s), 10988); + assert (round (Wn_p), 4000); + assert (round (Wn_s), 5829); ***** test # Digital notch (narrow band-stop) fs = 44100; - [n, Wn_p, Wn_s] = cheb2ord (2 / fs * [8500, 10834], ... + [n, Wn_p, Wn_s] = cheb1ord (2 / fs * [8500, 10834], ... 2 / fs * [9875, 10126.5823], 0.5, 40); Wn_p = Wn_p * fs / 2; Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn_p), [9804, 10198]); - assert (round (Wn_s), [9875, 10127]); + assert (round (Wn_p), [9182, 10834]); + assert (round (Wn_s), [9475, 10532]); ***** test # Digital notch (narrow band-stop) fs = 44100; - [n, Wn_p, Wn_s] = cheb2ord (2 / fs * [9182 12000], ... + [n, Wn_p, Wn_s] = cheb1ord (2 / fs * [9182 12000], ... 2 / fs * [9875, 10126.5823], 0.5, 40); Wn_p = Wn_p * fs / 2; Wn_s = Wn_s * fs / 2; assert (n, 3); - assert (round (Wn_p), [9804, 10198]); - assert (round (Wn_s), [9875, 10127]); -***** error cheb2ord () -***** error cheb2ord (.1) -***** error cheb2ord (.1, .2) -***** error cheb2ord (.1, .2, 3) -***** error cheb2ord ([.1 .1], [.2 .2], 3, 4) -***** error cheb2ord ([.1 .2], [.5 .6], 3, 4) -***** error cheb2ord ([.1 .5], [.2 .6], 3, 4) + assert (round (Wn_p), [9182, 10834]); + assert (round (Wn_s), [9475, 10532]); +***** error cheb1ord () +***** error cheb1ord (.1) +***** error cheb1ord (.1, .2) +***** error cheb1ord (.1, .2, 3) +***** error cheb1ord ([.1 .1], [.2 .2], 3, 4) +***** error cheb1ord ([.1 .2], [.5 .6], 3, 4) +***** error cheb1ord ([.1 .5], [.2 .6], 3, 4) 19 tests, 19 passed, 0 known failure, 0 skipped -[inst/statelevels.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/statelevels.m -***** error l = statelevels() -***** error l = statelevels("test") -***** error l = statelevels(1) -***** error l = statelevels([1 2 3], 'test') -***** error l = statelevels([1 2 3], 3, 'test') -***** error l = statelevels([1 2 3], 3, 'mode', 1) -***** error l = statelevels([1 2 3], 3, 'mode', [1 -1]) -***** shared X - t = linspace(0,2*pi*10,100); - X = square(t) + cos(t); -***** test - l = statelevels(X); - assert(l, [-1.9795 1.9800], 1e5) -***** test - [l, h] = statelevels(X); - assert(l, [-1.9795 1.9800], 1e5) - assert(sum(h), 100) - assert(length(h), 100) -***** test - [l, h, b] = statelevels(X); - assert(l, [-1.9795 1.9800], 1e5) - assert(sum(h), 100) - assert(length(h), 100) - assert(h(1), 4) - assert(h(2), 2) - assert(h(4), 1) - assert(h(11), 0) - assert(b(1), -1.9795, 1e5) - assert(b(2), -1.9395, 1e5) -***** test - [l, h, b] = statelevels(X, 100); - assert(l, [-1.9795 1.9800], 1e5) - assert(sum(h), 100) - assert(length(h), 100) - assert(h(1), 4) - assert(h(2), 2) - assert(h(4), 1) - assert(h(11), 0) - assert(b(1), -1.9795, 1e5) - assert(b(2), -1.9395, 1e5) -***** test - [l, h, b] = statelevels(X, 50); - assert(l, [-1.9595 1.9600], 1e5) - assert(sum(h), 100) - assert(length(h), 50) - assert(h(1), 6) - assert(h(2), 3) - assert(h(4), 2) - assert(h(11), 1) - assert(b(1), -1.9595, 1e5) - assert(b(2), -1.8795, 1e5) -***** test - [l, h, b] = statelevels(X, 100, 'mode'); - assert(l, [-1.9795 1.9800], 1e5) - assert(sum(h), 100) - assert(length(h), 100) - assert(h(1), 4) - assert(h(2), 2) - assert(h(4), 1) - assert(h(11), 0) - assert(b(1), -1.9795, 1e5) - assert(b(2), -1.9395, 1e5) -***** test - [l, h, b] = statelevels(X, 100, 'mean'); - assert(l, [-1.0090 0.9532], 1e5) - assert(sum(h), 100) - assert(length(h), 100) - assert(h(1), 4) - assert(h(2), 2) - assert(h(4), 1) - assert(h(11), 0) - assert(b(1), -1.9795, 1e5) - assert(b(2), -1.9395, 1e5) -***** test - [l, h, b] = statelevels(X, 100, 'mode', [-1.8 1.0]); - assert(l, [-1.7860 0.0060], 1e5) - assert(sum(h), 64) - assert(length(h), 100) - assert(h(1), 1) - assert(h(2), 1) - assert(h(3), 0) - assert(b(1), -1.7860, 1e5) - assert(b(2), -1.7580, 1e5) -***** demo - # Generate test signal - t = linspace(0,2*pi*10,100); - X = square(t) + cos(t); - # plot the waveform and provide the levels - statelevels(X) -15 tests, 15 passed, 0 known failure, 0 skipped -[inst/digitrevorder.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/digitrevorder.m -***** assert (digitrevorder (0, 2), 0); -***** assert (digitrevorder (0, 36), 0); -***** assert (digitrevorder (0:3, 4), 0:3); -***** assert (digitrevorder ([0:3]', 4), [0:3]'); -***** assert (digitrevorder (0:7, 2), [0 4 2 6 1 5 3 7]); -***** assert (digitrevorder ([0:7]', 2), [0 4 2 6 1 5 3 7]'); -***** assert (digitrevorder ([0:7]*i, 2), [0 4 2 6 1 5 3 7]*i); -***** assert (digitrevorder ([0:7]'*i, 2), [0 4 2 6 1 5 3 7]'*i); -***** assert (digitrevorder (0:15, 2), [0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15]); -***** assert (digitrevorder (0:15, 4), [0 4 8 12 1 5 9 13 2 6 10 14 3 7 11 15]); -***** error digitrevorder (); -***** error digitrevorder (1); -***** error digitrevorder (1, 2, 3); -***** error digitrevorder ([], 1); -***** error digitrevorder ([], 37); -***** error digitrevorder (0:3, 8); -16 tests, 16 passed, 0 known failure, 0 skipped -[inst/blackmanharris.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/blackmanharris.m -***** assert (blackmanharris (1), 1); -***** assert (blackmanharris (2), 0.00006 * ones (2, 1), eps); -***** assert (blackmanharris (15), flipud (blackmanharris (15)), 10*eps); -***** assert (blackmanharris (16), flipud (blackmanharris (16)), 10*eps); -***** assert (blackmanharris (15), blackmanharris (15, "symmetric")); -***** assert (blackmanharris (16)(1:15), blackmanharris (15, "periodic")); -***** error blackmanharris () -***** error blackmanharris (0.5) -***** error blackmanharris (-1) -***** error blackmanharris (ones (1, 4)) -***** error blackmanharris (1, 2) -***** error blackmanharris (1, "invalid") -12 tests, 12 passed, 0 known failure, 0 skipped -[inst/fwhm.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/fwhm.m -***** test - x=-pi:0.001:pi; y=cos(x); - assert( abs(fwhm(x, y) - 2*pi/3) < 0.01 ); - -***** test - assert( fwhm(-10:10) == 0 && fwhm(ones(1,50)) == 0 ); - -***** test - x=-20:1:20; - y1=-4+zeros(size(x)); y1(4:10)=8; - y2=-2+zeros(size(x)); y2(4:11)=2; - y3= 2+zeros(size(x)); y3(5:13)=10; - assert( max(abs(fwhm(x, [y1;y2;y3]') - [20.0/3,7.5,9.25])) < 0.01 ); - -***** test - x=1:3; y=[-1,3,-1]; assert(abs(fwhm(x,y)-0.75)<0.001 && abs(fwhm(x,y,'zero')-0.75)<0.001 && abs(fwhm(x,y,'min')-1.0)<0.001); - -***** test - x=1:3; y=[-1,3,-1]; assert(abs(fwhm(x,y, 'rlevel', 0.1)-1.35)<0.001 && abs(fwhm(x,y,'zero', 'rlevel', 0.1)-1.35)<0.001 && abs(fwhm(x,y,'min', 'rlevel', 0.1)-1.40)<0.001); - -***** test - x=1:3; y=[-1,3,-1]; assert(abs(fwhm(x,y, 'alevel', 2.5)-0.25)<0.001 && abs(fwhm(x,y,'alevel', -0.5)-1.75)<0.001); - -***** test - x=-10:10; assert( fwhm(x.*x) == 0 ); - -***** test - x=-5:5; y=18-x.*x; assert( abs(fwhm(y)-6.0) < 0.001 && abs(fwhm(x,y,'zero')-6.0) < 0.001 && abs(fwhm(x,y,'min')-7.0 ) < 0.001); -8 tests, 8 passed, 0 known failure, 0 skipped -[inst/tripuls.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/tripuls.m -***** demo - fs = 11025; # arbitrary sample rate - f0 = 100; # pulse train sample rate - w = 0.5/f0; # pulse width 1/10th the distance between pulses - x = pulstran (0:1/fs:4/f0, 0:1/f0:4/f0, "tripuls", w); - plot ([0:length(x)-1]*1000/fs, x); - xlabel ("Time (ms)"); - ylabel ("Amplitude"); - title ("Triangular pulse train of 5 ms pulses at 10 ms intervals"); -***** demo - fs = 11025; # arbitrary sample rate - f0 = 100; # pulse train sample rate - w = 0.5/f0; # pulse width 1/10th the distance between pulses - x = pulstran (0:1/fs:4/f0, 0:1/f0:4/f0, "tripuls", w, -0.5); - plot ([0:length(x)-1]*1000/fs, x); - xlabel ("Time (ms)"); - ylabel ("Amplitude"); - title ("Triangular pulse train of 5 ms pulses at 10 ms intervals, skew = -0.5"); -***** assert (tripuls ([]), []) -***** assert (tripuls ([], 0.1), []) -***** assert (tripuls (zeros (10, 1)), ones (10, 1)) -***** assert (tripuls (-1:1), [0, 1, 0]) -***** assert (tripuls (-5:5, 9), [0, 1, 3, 5, 7, 9, 7, 5, 3, 1, 0] / 9) -***** assert (tripuls (0:1/100:0.3, 0.1), tripuls ([0:1/100:0.3]', 0.1)') -***** error tripuls () -***** error tripuls (1, 2, 3, 4) -***** error tripuls (1, 2j) -***** error tripuls (1, 2, 2) -***** error tripuls (1, 2, -2) -11 tests, 11 passed, 0 known failure, 0 skipped -[inst/kaiser.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/kaiser.m -***** demo - % use demo("kaiserord"); -***** assert (kaiser (1), 1) -***** error kaiser () -***** error kaiser (0.5) -***** error kaiser (-1) -***** error kaiser (ones (1, 4)) -***** error kaiser (1, 2, 3) +Checking C++ files ... +[src/upfirdn.cc] +>>>>> /build/reproducible-path/octave-signal-1.4.5/src/upfirdn.cc +***** assert (isequal (upfirdn (1:100, 1, 1, 1), 1:100)) +***** assert (isequal (upfirdn (1:100, 1, 1, 2), 1:2:100)) +***** error upfirdn () +***** error upfirdn (1,2) +***** error upfirdn (1,2,3) +***** error upfirdn (1,2,3,4,5) 6 tests, 6 passed, 0 known failure, 0 skipped -[inst/residued.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/residued.m -***** test - B=1; A=[1 -1]; - [r,p,f,m] = residued(B,A); - assert({r,p,f,m},{1,1,[],1},100*eps); - [r2,p2,f2,m2] = residuez(B,A); - assert({r,p,f,m},{r2,p2,f2,m2},100*eps); -***** test - B=[1 -2 1]; A=[1 -1]; - [r,p,f,m] = residued(B,A); - assert({r,p,f,m},{0,1,[1 -1],1},100*eps); -***** test - B=[1 -2 1]; A=[1 -0.5]; - [r,p,f,m] = residued(B,A); - assert({r,p,f,m},{0.25,0.5,[1 -1.5],1},100*eps); -***** test - B=1; A=[1 -0.75 0.125]; - [r,p,f,m] = residued(B,A); - [r2,p2,f2,m2] = residuez(B,A); - assert({r,p,f,m},{r2,p2,f2,m2},100*eps); -***** test - B=1; A=[1 -2 1]; - [r,p,f,m] = residued(B,A); - [r2,p2,f2,m2] = residuez(B,A); - assert({r,p,f,m},{r2,p2,f2,m2},100*eps); -***** test - B=[6,2]; A=[1 -2 1]; - [r,p,f,m] = residued(B,A); - [r2,p2,f2,m2] = residuez(B,A); - assert({r,p,f,m},{r2,p2,f2,m2},100*eps); -***** test - B=[1 1 1]; A=[1 -2 1]; - [r,p,f,m] = residued(B,A); - assert(r,[0;3],1e-7); - assert(p,[1;1],1e-8); - assert(f,1,100*eps); - assert(m,[1;2],100*eps); -***** test - B=[2 6 6 2]; A=[1 -2 1]; - [r,p,f,m] = residued(B,A); - assert(r,[8;16],3e-7); - assert(p,[1;1],1e-8); - assert(f,[2,10],100*eps); - assert(m,[1;2],100*eps); -***** test - B=[1,6,2]; A=[1 -2 1]; - [r,p,f,m] = residued(B,A); - assert(r,[-1;9],3e-7); - assert(p,[1;1],1e-8); - assert(f,1,100*eps); - assert(m,[1;2],100*eps); -***** test - B=[1 0 0 0 1]; A=[1 0 0 0 -1]; - [r,p,f,m] = residued(B,A); - [~,is] = sort(angle(p)); - assert(r(is),[-1/2;-j/2;1/2;j/2],100*eps); - assert(p(is),[-1;-j;1;j],100*eps); - assert(f,1,100*eps); - assert(m,[1;1;1;1],100*eps); -10 tests, 10 passed, 0 known failure, 0 skipped -[inst/marcumq.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/marcumq.m -***** error marcumq (1) -***** error marcumq (-1, 1, 1, 1, 1) -***** error marcumq (-1, 1) -***** error marcumq (1, -1) -***** error marcumq (1, 1, 0) -***** error marcumq (1, 1, -1) -***** error marcumq (1, 1, 1.1) -***** test - a = [0.00; 0.05; 1.00; 2.00; 3.00; 4.00; 5.00; 6.00; 7.00; 8.00; 9.00; 10.00; - 11.00; 12.00; 13.00; 14.00; 15.00; 16.00; 17.00; 18.00; 19.00; 20.00; - 21.00; 22.00; 23.00; 24.00]; - b = [0.000000, 0.100000, 1.100000, 2.100000, 3.100000, 4.100000]; - Q = [1.000000, 0.995012, 0.546074, 0.110251, 0.008189, 0.000224; - 1.000000, 0.995019, 0.546487, 0.110554, 0.008238, 0.000226; - 1.000000, 0.996971, 0.685377, 0.233113, 0.034727, 0.002092; - 1.000000, 0.999322, 0.898073, 0.561704, 0.185328, 0.027068; - 1.000000, 0.999944, 0.985457, 0.865241, 0.526735, 0.169515; - 1.000000, 0.999998, 0.999136, 0.980933, 0.851679, 0.509876; - 1.000000, 1.000000, 0.999979, 0.998864, 0.978683, 0.844038; - 1.000000, 1.000000, 1.000000, 0.999973, 0.998715, 0.977300; - 1.000000, 1.000000, 1.000000, 1.000000, 0.999969, 0.998618; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999966; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000]; - q = marcumq (a, b); - assert (q, Q, 1e-6); -***** test - a = [0.00; 0.05; 1.00; 2.00; 3.00; 4.00; 5.00; 6.00; 7.00; 8.00; 9.00; 10.00; - 11.00; 12.00; 13.00; 14.00; 15.00; 16.00; 17.00; 18.00; 19.00; 20.00; - 21.00; 22.00; 23.00; 24.00]; - b = [5.100000, 6.100000, 7.100000, 8.100000, 9.100000, 10.10000]; - Q = [0.000002, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; - 0.000002, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; - 0.000049, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; - 0.001606, 0.000037, 0.000000, 0.000000, 0.000000, 0.000000; - 0.024285, 0.001420, 0.000032, 0.000000, 0.000000, 0.000000; - 0.161412, 0.022812, 0.001319, 0.000030, 0.000000, 0.000000; - 0.499869, 0.156458, 0.021893, 0.001256, 0.000028, 0.000000; - 0.839108, 0.493229, 0.153110, 0.021264, 0.001212, 0.000027; - 0.976358, 0.835657, 0.488497, 0.150693, 0.020806, 0.001180; - 0.998549, 0.975673, 0.833104, 0.484953, 0.148867, 0.020458; - 0.999965, 0.998498, 0.975152, 0.831138, 0.482198, 0.147437; - 1.000000, 0.999963, 0.998458, 0.974742, 0.829576, 0.479995; - 1.000000, 1.000000, 0.999962, 0.998426, 0.974411, 0.828307; - 1.000000, 1.000000, 1.000000, 0.999961, 0.998400, 0.974138; - 1.000000, 1.000000, 1.000000, 1.000000, 0.999960, 0.998378; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999960; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000]; - q = marcumq (a, b); - assert (q, Q, 1e-6); -***** test - a = [0.00; 0.05; 1.00; 2.00; 3.00; 4.00; 5.00; 6.00; 7.00; 8.00; 9.00; 10.00; - 11.00; 12.00; 13.00; 14.00; 15.00; 16.00; 17.00; 18.00; 19.00; 20.00; - 21.00; 22.00; 23.00; 24.00]; - b = [11.10000, 12.10000, 13.10000, 14.10000, 15.10000, 16.10000]; - Q = [0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; - 0.000026, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000; - 0.001155, 0.000026, 0.000000, 0.000000, 0.000000, 0.000000; - 0.020183, 0.001136, 0.000025, 0.000000, 0.000000, 0.000000; - 0.146287, 0.019961, 0.001120, 0.000025, 0.000000, 0.000000; - 0.478193, 0.145342, 0.019778, 0.001107, 0.000024, 0.000000; - 0.827253, 0.476692, 0.144551, 0.019625, 0.001096, 0.000024; - 0.973909, 0.826366, 0.475422, 0.143881, 0.019494, 0.001087; - 0.998359, 0.973714, 0.825607, 0.474333, 0.143304, 0.019381; - 0.999959, 0.998343, 0.973546, 0.824952, 0.473389, 0.142803; - 1.000000, 0.999959, 0.998330, 0.973400, 0.824380, 0.472564; - 1.000000, 1.000000, 0.999958, 0.998318, 0.973271, 0.823876; - 1.000000, 1.000000, 1.000000, 0.999958, 0.998307, 0.973158; - 1.000000, 1.000000, 1.000000, 1.000000, 0.999957, 0.998297; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999957; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000]; - q = marcumq (a, b); - assert (q, Q, 1e-6); -***** test - a = [0.00; 0.05; 1.00; 2.00; 3.00; 4.00; 5.00; 6.00; 7.00; 8.00; 9.00; 10.00; - 11.00; 12.00; 13.00; 14.00; 15.00; 16.00; 17.00; 18.00; 19.00; 20.00; - 21.00; 22.00; 23.00; 24.00]; - b = [17.10000, 18.10000, 19.10000]; - Q = [0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000; - 0.000000, 0.000000, 0.000000; - 0.000024, 0.000000, 0.000000; - 0.001078, 0.000024, 0.000000; - 0.019283, 0.001071, 0.000023; - 0.142364, 0.019197, 0.001065; - 0.471835, 0.141976, 0.019121; - 0.823429, 0.471188, 0.141630; - 0.973056, 0.823030, 0.470608; - 0.998289, 0.972965, 0.822671; - 0.999957, 0.998281, 0.972883; - 1.000000, 0.999957, 0.998274; - 1.000000, 1.000000, 0.999956; - 1.000000, 1.000000, 1.000000]; - q = marcumq (a, b); - assert (q, Q, 1e-6); -***** test - M = 2; - a = [0.00; 0.05; 1.00; 2.00; 3.00; 4.00; 5.00; 6.00; 7.00; 8.00; 9.00; 10.00; - 11.00; 12.00; 13.00; 14.00; 15.00; 16.00; 17.00; 18.00; 19.00; 20.00; - 21.00; 22.00; 23.00; 24.00]; - b = [ 0.00, 0.10, 2.10, 7.10, 12.10, 17.10]; - Q = [1.000000, 0.999987, 0.353353, 0.000000, 0.000000, 0.000000; - 1.000000, 0.999988, 0.353687, 0.000000, 0.000000, 0.000000; - 1.000000, 0.999992, 0.478229, 0.000000, 0.000000, 0.000000; - 1.000000, 0.999999, 0.745094, 0.000001, 0.000000, 0.000000; - 1.000000, 1.000000, 0.934771, 0.000077, 0.000000, 0.000000; - 1.000000, 1.000000, 0.992266, 0.002393, 0.000000, 0.000000; - 1.000000, 1.000000, 0.999607, 0.032264, 0.000000, 0.000000; - 1.000000, 1.000000, 0.999992, 0.192257, 0.000000, 0.000000; - 1.000000, 1.000000, 1.000000, 0.545174, 0.000000, 0.000000; - 1.000000, 1.000000, 1.000000, 0.864230, 0.000040, 0.000000; - 1.000000, 1.000000, 1.000000, 0.981589, 0.001555, 0.000000; - 1.000000, 1.000000, 1.000000, 0.998957, 0.024784, 0.000000; - 1.000000, 1.000000, 1.000000, 0.999976, 0.166055, 0.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 0.509823, 0.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 0.846066, 0.000032; - 1.000000, 1.000000, 1.000000, 1.000000, 0.978062, 0.001335; - 1.000000, 1.000000, 1.000000, 1.000000, 0.998699, 0.022409; - 1.000000, 1.000000, 1.000000, 1.000000, 0.999970, 0.156421; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.495223; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.837820; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.976328; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.998564; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999966; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000]; - q = marcumq (a, b, M); - assert (q, Q, 1e-6); -***** test - M = 5; - a = [0.00; 0.05; 1.00; 2.00; 3.00; 4.00; 5.00; 6.00; 7.00; 8.00; 9.00; 10.00; - 11.00; 12.00; 13.00; 14.00; 15.00; 16.00; 17.00; 18.00; 19.00; 20.00; - 21.00; 22.00; 23.00; 24.00]; - b = [ 0.00, 0.10, 2.10, 7.10, 12.10, 17.10]; - Q = [1.000000, 1.000000, 0.926962, 0.000000, 0.000000, 0.000000; - 1.000000, 1.000000, 0.927021, 0.000000, 0.000000, 0.000000; - 1.000000, 1.000000, 0.947475, 0.000001, 0.000000, 0.000000; - 1.000000, 1.000000, 0.980857, 0.000033, 0.000000, 0.000000; - 1.000000, 1.000000, 0.996633, 0.000800, 0.000000, 0.000000; - 1.000000, 1.000000, 0.999729, 0.011720, 0.000000, 0.000000; - 1.000000, 1.000000, 0.999990, 0.088999, 0.000000, 0.000000; - 1.000000, 1.000000, 1.000000, 0.341096, 0.000000, 0.000000; - 1.000000, 1.000000, 1.000000, 0.705475, 0.000002, 0.000000; - 1.000000, 1.000000, 1.000000, 0.933009, 0.000134, 0.000000; - 1.000000, 1.000000, 1.000000, 0.993118, 0.003793, 0.000000; - 1.000000, 1.000000, 1.000000, 0.999702, 0.045408, 0.000000; - 1.000000, 1.000000, 1.000000, 0.999995, 0.238953, 0.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 0.607903, 0.000001; - 1.000000, 1.000000, 1.000000, 1.000000, 0.896007, 0.000073; - 1.000000, 1.000000, 1.000000, 1.000000, 0.987642, 0.002480; - 1.000000, 1.000000, 1.000000, 1.000000, 0.999389, 0.034450; - 1.000000, 1.000000, 1.000000, 1.000000, 0.999988, 0.203879; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.565165; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.876284; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.984209; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999165; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999983; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000]; - q = marcumq (a, b, M); - assert (q, Q, 1e-6); -***** test - M = 10; - a = [0.00; 0.05; 1.00; 2.00; 3.00; 4.00; 5.00; 6.00; 7.00; 8.00; 9.00; 10.00; - 11.00; 12.00; 13.00; 14.00; 15.00; 16.00; 17.00; 18.00; 19.00; 20.00; - 21.00; 22.00; 23.00; 24.00]; - b = [ 0.00, 0.10, 2.10, 7.10, 12.10, 17.10]; - Q = [1.000000, 1.000000, 0.999898, 0.000193, 0.000000, 0.000000; - 1.000000, 1.000000, 0.999897, 0.000194, 0.000000, 0.000000; - 1.000000, 1.000000, 0.999931, 0.000416, 0.000000, 0.000000; - 1.000000, 1.000000, 0.999980, 0.002377, 0.000000, 0.000000; - 1.000000, 1.000000, 0.999997, 0.016409, 0.000000, 0.000000; - 1.000000, 1.000000, 0.999999, 0.088005, 0.000000, 0.000000; - 1.000000, 1.000000, 1.000000, 0.302521, 0.000000, 0.000000; - 1.000000, 1.000000, 1.000000, 0.638401, 0.000000, 0.000000; - 1.000000, 1.000000, 1.000000, 0.894322, 0.000022, 0.000000; - 1.000000, 1.000000, 1.000000, 0.984732, 0.000840, 0.000000; - 1.000000, 1.000000, 1.000000, 0.998997, 0.014160, 0.000000; - 1.000000, 1.000000, 1.000000, 0.999972, 0.107999, 0.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 0.391181, 0.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 0.754631, 0.000004; - 1.000000, 1.000000, 1.000000, 1.000000, 0.951354, 0.000266; - 1.000000, 1.000000, 1.000000, 1.000000, 0.995732, 0.006444; - 1.000000, 1.000000, 1.000000, 1.000000, 0.999843, 0.065902; - 1.000000, 1.000000, 1.000000, 1.000000, 0.999998, 0.299616; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.676336; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.925312; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.992390; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999679; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 0.999995; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000; - 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000]; - q = marcumq (a, b, M); - assert (q, Q, 1e-6); -14 tests, 14 passed, 0 known failure, 0 skipped -[inst/grpdelay.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/grpdelay.m -***** demo % 1 - %-------------------------------------------------------------- - % From Oppenheim and Schafer, a single zero of radius r=0.9 at - % angle pi should have a group delay of about -9 at 1 and 1/2 - % at zero and 2*pi. - %-------------------------------------------------------------- - grpdelay([1 0.9],[],512,'whole',1); - hold on; - xlabel('Normalized Frequency (cycles/sample)'); - stem([0, 0.5, 1],[0.5, -9, 0.5],'*b;target;'); - hold off; - title ('Zero at z = -0.9'); - -***** demo % 2 - %-------------------------------------------------------------- - % confirm the group delays approximately meet the targets - % don't worry that it is not exact, as I have not entered - % the exact targets. - %-------------------------------------------------------------- - b = poly([1/0.9*exp(1i*pi*0.2), 0.9*exp(1i*pi*0.6)]); - a = poly([0.9*exp(-1i*pi*0.6), 1/0.9*exp(-1i*pi*0.2)]); - grpdelay(b,a,512,'whole',1); - hold on; - xlabel('Normalized Frequency (cycles/sample)'); - stem([0.1, 0.3, 0.7, 0.9], [9, -9, 9, -9],'*b;target;'); - hold off; - title ('Two Zeros and Two Poles'); -***** demo % 3 - %-------------------------------------------------------------- - % fir lowpass order 40 with cutoff at w=0.3 and details of - % the transition band [.3, .5] - %-------------------------------------------------------------- - subplot(211); - Fs = 8000; % sampling rate - Fc = 0.3*Fs/2; % lowpass cut-off frequency - nb = 40; - b = fir1(nb,2*Fc/Fs); % matlab freq normalization: 1=Fs/2 - [H,f] = freqz(b,1,[],1); - [gd,f] = grpdelay(b,1,[],1); - plot(f,20*log10(abs(H))); - title(sprintf('b = fir1(%d,2*%d/%d);',nb,Fc,Fs)); - xlabel('Normalized Frequency (cycles/sample)'); - ylabel('Amplitude Response (dB)'); - grid('on'); - subplot(212); - del = nb/2; % should equal this - plot(f,gd); - title(sprintf('Group Delay in Pass-Band (Expect %d samples)',del)); - ylabel('Group Delay (samples)'); - axis([0, 0.2, del-1, del+1]); -***** demo % 4 - %-------------------------------------------------------------- - % IIR bandstop filter has delays at [1000, 3000] - %-------------------------------------------------------------- - Fs = 8000; - [b, a] = cheby1(3, 3, 2*[1000, 3000]/Fs, 'stop'); - [H,f] = freqz(b,a,[],Fs); - [gd,f] = grpdelay(b,a,[],Fs); - subplot(211); - plot(f,abs(H)); - title('[b,a] = cheby1(3, 3, 2*[1000, 3000]/Fs, "stop");'); - xlabel('Frequency (Hz)'); - ylabel('Amplitude Response'); - grid('on'); - subplot(212); - plot(f,gd); - title('[gd,f] = grpdelay(b,a,[],Fs);'); - ylabel('Group Delay (samples)'); -***** test % 00 - [gd1,w] = grpdelay([0,1]); - [gd2,w] = grpdelay([0,1],1); - assert(gd1,gd2,10*eps); -***** test % 0A - [gd,w] = grpdelay([0,1],1,4); - assert(gd,[1;1;1;1]); - assert(w,pi/4*[0:3]',10*eps); -***** test % 0B - [gd,w] = grpdelay([0,1],1,4,'whole'); - assert(gd,[1;1;1;1]); - assert(w,pi/2*[0:3]',10*eps); -***** test % 0C - [gd,f] = grpdelay([0,1],1,4,0.5); - assert(gd,[1;1;1;1]); - assert(f,1/16*[0:3]',10*eps); -***** test % 0D - [gd,w] = grpdelay([0,1],1,4,'whole',1); - assert(gd,[1;1;1;1]); - assert(w,1/4*[0:3]',10*eps); -***** test % 0E - [gd,f] = grpdelay([1 -0.9j],[],4,'whole',1); - gd0 = 0.447513812154696; gdm1 =0.473684210526316; - assert(gd,[gd0;-9;gd0;gdm1],20*eps); - assert(f,1/4*[0:3]',10*eps); -***** test % 1A: - gd= grpdelay(1,[1,.9],2*pi*[0,0.125,0.25,0.375]); - assert(gd, [-0.47368;-0.46918;-0.44751;-0.32316],1e-5); -***** test % 1B: - gd= grpdelay(1,[1,.9],[0,0.125,0.25,0.375],1); - assert(gd, [-0.47368;-0.46918;-0.44751;-0.32316],1e-5); -***** test % 2: - gd = grpdelay([1,2],[1,0.5,.9],4); - assert(gd,[-0.29167;-0.24218;0.53077;0.40658],1e-5); -***** test % 3 - b1=[1,2];a1f=[0.25,0.5,1];a1=fliplr(a1f); - % gd1=grpdelay(b1,a1,4); - gd=grpdelay(conv(b1,a1f),1,4)-2; - assert(gd, [0.095238;0.239175;0.953846;1.759360],1e-5); -***** test % 4 - warning ("off", "signal:grpdelay-singularity", "local"); - Fs = 8000; - [b, a] = cheby1(3, 3, 2*[1000, 3000]/Fs, 'stop'); - [h, w] = grpdelay(b, a, 256, 'half', Fs); - [h2, w2] = grpdelay(b, a, 512, 'whole', Fs); - assert (size(h), size(w)); - assert (length(h), 256); - assert (size(h2), size(w2)); - assert (length(h2), 512); - assert (h, h2(1:256)); - assert (w, w2(1:256)); -***** test % 5 - a = [1 0 0.9]; - b = [0.9 0 1]; - [dh, wf] = grpdelay(b, a, 512, 'whole'); - [da, wa] = grpdelay(1, a, 512, 'whole'); - [db, wb] = grpdelay(b, 1, 512, 'whole'); - assert(dh,db+da,1e-5); -***** test - DR= [1.00000 -0.00000 -3.37219 0.00000 ... - 5.45710 -0.00000 -5.24394 0.00000 ... - 3.12049 -0.00000 -1.08770 0.00000 0.17404]; - N = [-0.0139469 -0.0222376 0.0178631 0.0451737 ... - 0.0013962 -0.0259712 0.0016338 0.0165189 ... - 0.0115098 0.0095051 0.0043874]; - assert (nthargout (1:2, @grpdelay, N, DR, 1024), - nthargout (1:2, @grpdelay, N', DR', 1024)); -13 tests, 13 passed, 0 known failure, 0 skipped -[inst/impz.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/impz.m -***** assert (size (impz (1, [1 -1 0.9], 100)), [100 1]) -***** xtest - [h, t] = impz (1, [1 -1 0.9], 0:101); - assert (size (h), [101 1]) - assert (t, 0:101) -!!!!! known failure -impz: N must be empty or a scalar -2 tests, 1 passed, 1 known failure, 0 skipped -[inst/dst.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/dst.m -***** test - x = log(linspace(0.1,1,32)); - y = dst(x); - assert(y(3), sum(x.*sin(3*pi*[1:32]/33)), 100*eps) +[src/__fwht__.cc] +>>>>> /build/reproducible-path/octave-signal-1.4.5/src/__fwht__.cc +***** assert (1) 1 test, 1 passed, 0 known failure, 0 skipped -[inst/tukeywin.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/tukeywin.m -***** demo - m = 100; - r = 1/3; - w = tukeywin (m, r); - title(sprintf("%d-point Tukey window, R = %d/%d", m, [p, q] = rat(r), q)); - plot(w); -***** assert (tukeywin (1), 1) -***** assert (tukeywin (2), zeros (2, 1)) -***** assert (tukeywin (3), [0; 1; 0]) -***** assert (tukeywin (16, 0), rectwin (16)) -***** assert (tukeywin (16, 1), hanning (16)) -***** error tukeywin () -***** error tukeywin (0.5) -***** error tukeywin (-1) -***** error tukeywin (ones (1, 4)) -***** error tukeywin (1, 2, 3) -10 tests, 10 passed, 0 known failure, 0 skipped -[inst/rectwin.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/rectwin.m -***** assert (rectwin (1), 1) -***** assert (rectwin (2), ones (2, 1)) -***** assert (rectwin (100), ones (100, 1)) -***** error rectwin () -***** error rectwin (0.5) -***** error rectwin (-1) -***** error rectwin (ones (1, 4)) -***** error rectwin (1, 2) -8 tests, 8 passed, 0 known failure, 0 skipped -[inst/rceps.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/rceps.m -***** test - ## accepts matrices - x = randn (32, 3); - [y, xm] = rceps (x); - ## check the mag-phase response of the reproduction - hx = fft (x); - hxm = fft (xm); - assert (abs (hx), abs (hxm), 200*eps); # good magnitude response match - ## FIXME: test for minimum phase? Stop using random datasets! - #assert (arg (hx) != arg (hxm)); # phase mismatch -***** test - ## accepts column and row vectors - x = randn (256, 1); - [y, xm] = rceps (x); - [yt, xmt] = rceps (x.'); - assert (yt.', y, 1e-14); - assert (xmt.', xm, 1e-14); -***** test - x = randn (33, 4); - [y, xm] = rceps (x); - assert (size (y), size (x)); - assert (size (xm), size (x)); -***** error rceps -***** error rceps (1, 2) -***** error rceps (0) -***** error rceps (zeros (10, 1)) -***** demo - f0 = 70; Fs = 10000; # 100 Hz fundamental, 10 kHz sampling rate - a = real (poly (0.985 * exp (1i * pi * [0.1, -0.1, 0.3, -0.3]))); # two formants - s = 0.05 * randn (1024, 1); # Noise excitation signal - s(floor (1:Fs/f0:length (s))) = 1; # Impulse glottal wave - x = filter (1, a, s); # Speech signal in x - [y, xm] = rceps (x); # cepstrum and minimum phase x - [hx, w] = freqz (x, 1, [], Fs); - hxm = freqz (xm); - figure (1); - subplot (311); - len = 1000 * fix (min (length (x), length (xm)) / 1000); - plot ([0:len-1] * 1000 / Fs, x(1:len), "b;signal;", ... - [0:len-1] * 1000 / Fs, xm(1:len), "g;reconstruction;"); - ylabel ("Amplitude"); - xlabel ("Time (ms)"); - subplot (312); - axis ("ticy"); - plot (w, log (abs (hx)), ";magnitude;", ... - w, log (abs (hxm)), ";reconstruction;"); - xlabel ("Frequency (Hz)"); - subplot (313); - axis ("on"); - plot (w, unwrap (arg (hx)) / (2 * pi), ";phase;", ... - w, unwrap (arg (hxm)) / (2 * pi), ";reconstruction;"); - xlabel ("Frequency (Hz)"); - len = 1000 * fix (length (y) / 1000); - figure (2); - plot ([0:len-1] * 1000 / Fs, y(1:len), ";cepstrum;"); - ylabel ("Amplitude"); - xlabel ("Quefrency (ms)"); - %------------------------------------------------------------- - % confirm the magnitude spectrum is identical in the signal - % and the reconstruction and that there are peaks in the - % cepstrum at 14 ms intervals corresponding to an F0 of 70 Hz. -7 tests, 7 passed, 0 known failure, 0 skipped -[inst/cheby2.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cheby2.m -***** error [a, b] = cheby2 () -***** error [a, b] = cheby2 (1) -***** error [a, b] = cheby2 (1, 2) -***** error [a, b] = cheby2 (1, 2, 3, 4, 5, 6) -***** error [a, b] = cheby2 (.5, 40, .2) -***** error [a, b] = cheby2 (3, 40, .2, "invalid") -***** test - cheby2 (3, 4, .5); - assert (isrow (ans)); -***** test - A = cheby2 (3, 4, .5); - assert (isrow (A)); -***** test - [A, B] = cheby2 (3, 4, .5); - assert (isrow (A)); - assert (isrow (B)); -***** test - [z, p, g] = cheby2 (3, 4, .5); - assert (iscolumn (z)); - assert (iscolumn (p)); - assert (isscalar (g)); -***** test - [a, b, c, d] = cheby2 (3, 4, .5); - assert (ismatrix (a)); - assert (iscolumn (b)); - assert (isrow (c)); - assert (isscalar (d)); -11 tests, 11 passed, 0 known failure, 0 skipped -[inst/ismaxphase.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/ismaxphase.m -***** demo - [b, a] = butter (1, .5); - f = ismaxphase (b, a) -***** error n = ismaxphase () -***** error n = ismaxphase (1, 1, 1, 1) -***** error n = ismaxphase (1, 1, 1, 1, 1) -***** error n = ismaxphase ([1:10]', 1) -***** error n = ismaxphase (1, [1:10]') -***** error n = ismaxphase ([1:10]', [1:10]') -***** error n = ismaxphase (1:10, 1:10, 1:10) -***** error n = ismaxphase (ones (3), ones (3)) -***** test - z1 = [0.9*exp(j*0.6*pi), 0.9*exp(-j*0.6*pi)]; - z2 = [0.8*exp(j*0.8*pi), 0.8*exp(-j*0.8*pi)]; - b = poly ([z1 z2]); - a = 1; - f = ismaxphase (b, a); - assert (f, false) -***** test - z1 = [0.9*exp(j*0.6*pi), 0.9*exp(-j*0.6*pi)]; - z2 = [0.8*exp(j*0.8*pi), 0.8*exp(-j*0.8*pi)]; - b = poly ([1./z1 1./z2]); - a = 1; - f = ismaxphase (b, a); - assert (f, true) -***** test - z1 = [0.9*exp(j*0.6*pi), 0.9*exp(-j*0.6*pi)]; - z2 = [0.8*exp(j*0.8*pi), 0.8*exp(-j*0.8*pi)]; - b = poly ([z1 1./z2]); - a = 1; - f = ismaxphase (b, a); - assert (f, false) -***** test - z1 = [0.9*exp(j*0.6*pi), 0.9*exp(-j*0.6*pi)]; - z2 = [0.8*exp(j*0.8*pi), 0.8*exp(-j*0.8*pi)]; - b = poly ([1./z1 z2]); - a = 1; - f = ismaxphase (b, a); - assert (f, false) -***** test - [b, a] = butter (1, .5); - f = ismaxphase (b, a); - assert (f, false) -***** test - [b, a] = butter (8, .5); - f = ismaxphase (b, a); - assert (f, false) -14 tests, 14 passed, 0 known failure, 0 skipped -[inst/flattopwin.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/flattopwin.m -***** assert (flattopwin (1), 1); -***** assert (flattopwin (2), 0.0042 / 4.6402 * ones (2, 1), eps); -***** assert (flattopwin (15), flipud (flattopwin (15)), 10*eps); -***** assert (flattopwin (16), flipud (flattopwin (16)), 10*eps); -***** assert (flattopwin (15), flattopwin (15, "symmetric")); -***** assert (flattopwin (16)(1:15), flattopwin (15, "periodic")); -***** error flattopwin () -***** error flattopwin (0.5) -***** error flattopwin (-1) -***** error flattopwin (ones (1, 4)) -***** error flattopwin (1, 2) -***** error flattopwin (1, 2, 3) -***** error flattopwin (1, "invalid") -13 tests, 13 passed, 0 known failure, 0 skipped -[inst/isallpass.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/isallpass.m -***** demo - # H(z) = (b1 - z^-1) * (b2 - z^-1) / ((1 - b1*z^-1) * (1 - b2*z^-1)) - b1 = 0.5 * (1 + i); - b2 = 0.7 * (cos (pi/6) + i*sin (pi/6)); - b = conv ([b1 -1], [b2 -1]); - a = conv ([1 (-1)*conj(b1)],[1 (-1)*conj(b2)]); - freqz (b, a); - f = isallpass (b, a) - ## test input validation -***** error n = isallpass () -***** error n = isallpass (1) -***** error n = isallpass (1, 1, 1) -***** error n = isallpass (1, 1, 1, 1) -***** error n = isallpass (1, 1, 1, 1, 1) -***** error n = isallpass ([1:10]', 1) -***** error n = isallpass (1, [1:10]') -***** error n = isallpass ([1:10]', [1:10]') -***** error n = isallpass (1:10, 1:10, 1:10) -***** error n = isallpass (ones (3), ones (3)) -***** test - b = [(1+i)/2 -1]; - a = [1 -(1-i)/2]; - f = isallpass (b, a); - assert (f, true) -***** test - b = [(1+i)/2 -1]; - a = [-1 (1-i)/2]; - f = isallpass (b, a); - assert (f, true) -***** test - [b, a] = butter (1, 0.5); - f = isallpass (b, a); - assert (f, false) -***** test - b1 = 0.5 * (1 + i); - b2 = 0.7 * (cos (pi/6) + i*sin (pi/6)); - b = conv ([b1 -1], [b2 -1]); - a = conv ([1 -conj(b1)],[1, -conj(b2)]); - f = isallpass (b, a); - assert (f, true) -14 tests, 14 passed, 0 known failure, 0 skipped -[inst/resample.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/resample.m -***** test - N=512; - p=3; q=5; - r=p/q; - NN=ceil(r*N); - t=0:N-1; - tt=0:NN-1; - err=zeros(N/2,1); - for n = 0:N/2-1, - phi0=2*pi*rand; - f0=n/N; - x=sin(2*pi*f0*t' + phi0); - [y,h]=resample(x,p,q); - xx=sin(2*pi*f0/r*tt' + phi0); - t0=ceil((length(h)-1)/2/q); - idx=t0+1:NN-t0; - err(n+1)=max(abs(y(idx)-xx(idx))); - endfor; - rolloff=.1; - rejection=10^-3; - idx_inband=1:ceil((1-rolloff/2)*r*N/2)-1; - assert(max(err(idx_inband))>>>> /build/reproducible-path/octave-signal-1.4.5/inst/fwht.m -***** assert (isempty (fwht ([]))); -***** assert (fwht (zeros (16)), zeros (16)); -***** assert (fwht (ones (16, 1)), [1; (zeros (15, 1))]); -***** assert (fwht (zeros (17, 1)), zeros (32, 1)); -***** assert (fwht ([1 -1 1 -1 1 -1 1 -1]), [0 0 0 0 0 0 0 1]); -***** test - x = randi (16, 16); - assert (ifwht (fwht (x)), x); -***** test - x = randi (16, 16); - assert (ifwht (fwht (x, [], "sequency"), [], "sequency"), x); -***** test - x = randi (16, 16); - assert (ifwht (fwht (x, [], "hadamard"), [], "hadamard"), x); -***** test - x = randi (16, 16); - assert (ifwht (fwht (x, [], "dyadic"), [], "dyadic"), x); -***** error fwht (); -***** error fwht (1, 2, 3, 4); -***** error fwht (0, 0); -***** error fwht (0, 5); -***** error fwht (0, [], "invalid"); -14 tests, 14 passed, 0 known failure, 0 skipped -[inst/impinvar.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/impinvar.m -***** function err = stozerr(bs,as,fs) - - # number of time steps - n=100; - - # impulse invariant transform to z-domain - [bz az]=impinvar(bs,as,fs); - - # create sys object of transfer function - s=tf(bs,as); - - # calculate impulse response of continuous time system - # at discrete time intervals 1/fs - ys=impulse(s,(n-1)/fs,1/fs)'; - - # impulse response of discrete time system - yz=filter(bz,az,[1 zeros(1,n-1)]); - - # find rms error - err=sqrt(sum((yz*fs-ys).^2)/length(ys)); - endfunction - -***** assert(stozerr([1],[1 1],100),0,0.0001); -***** assert(stozerr([1],[1 2 1],100),0,0.0001); -***** assert(stozerr([1 1],[1 2 1],100),0,0.0002); -***** assert(stozerr([1],[1 3 3 1],100),0,0.0001); -***** assert(stozerr([1 1],[1 3 3 1],100),0,0.0001); -***** assert(stozerr([1 1 1],[1 3 3 1],100),0,0.0001); -***** assert(stozerr([1],[1 0 1],100),0,0.0001); -***** assert(stozerr([1 1],[1 0 1],100),0,0.0001); -***** assert(stozerr([1],[1 0 2 0 1],100),0,0.0001); -***** assert(stozerr([1 1],[1 0 2 0 1],100),0,0.0001); -***** assert(stozerr([1 1 1],[1 0 2 0 1],100),0,0.0001); -***** assert(stozerr([1 1 1 1],[1 0 2 0 1],100),0,0.0001); -12 tests, 12 passed, 0 known failure, 0 skipped -[inst/findpeaks.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/findpeaks.m -***** demo - t = 2*pi*linspace(0,1,1024)'; - y = sin(3.14*t) + 0.5*cos(6.09*t) + 0.1*sin(10.11*t+1/6) + 0.1*sin(15.3*t+1/3); - - data1 = abs(y); # Positive values - [pks idx] = findpeaks(data1); - - data2 = y; # Double-sided - [pks2 idx2] = findpeaks(data2,"DoubleSided"); - [pks3 idx3] = findpeaks(data2,"DoubleSided","MinPeakHeight",0.5); - - subplot(1,2,1) - plot(t,data1,t(idx),data1(idx),'xm') - axis tight - subplot(1,2,2) - plot(t,data2,t(idx2),data2(idx2),"xm;>2*std;",t(idx3),data2(idx3),"or;>0.1;") - axis tight - legend("Location","NorthOutside","Orientation","horizontal") - - #---------------------------------------------------------------------------- - # Finding the peaks of smooth data is not a big deal! -***** demo - t = 2*pi*linspace(0,1,1024)'; - y = sin(3.14*t) + 0.5*cos(6.09*t) + 0.1*sin(10.11*t+1/6) + 0.1*sin(15.3*t+1/3); - - data = abs(y + 0.1*randn(length(y),1)); # Positive values + noise - [pks idx] = findpeaks(data,"MinPeakHeight",1); - - dt = t(2)-t(1); - [pks2 idx2] = findpeaks(data,"MinPeakHeight",1,... - "MinPeakDistance",round(0.5/dt)); - - subplot(1,2,1) - plot(t,data,t(idx),data(idx),'or') - subplot(1,2,2) - plot(t,data,t(idx2),data(idx2),'or') - - #---------------------------------------------------------------------------- - # Noisy data may need tuning of the parameters. In the 2nd example, - # MinPeakDistance is used as a smoother of the peaks. -***** assert (isempty (findpeaks ([1, 1, 1]))) -***** assert (isempty (findpeaks ([1; 1; 1]))) -***** test - ## Test input vector is an oversampled sinusoid with clipped peaks - x = min (3, cos (2*pi*[0:8000] ./ 600) + 2.01); - assert (! isempty (findpeaks (x))) -***** test - x = [1 10 2 2 1 9 1]; - [pks, loc] = findpeaks(x); - assert (loc, [2 6]) - assert (pks, [10 9]) -***** error findpeaks () -***** error findpeaks (1) -***** error findpeaks ([1, 2]) -***** test assert (findpeaks ([34 134 353 64 134 14 56 67 234 143 64 575 8657]), - [353 134 234]) -8 tests, 8 passed, 0 known failure, 0 skipped -[inst/uencode.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/uencode.m -***** test - u = [-3:0.5:3]; - y = uencode (u, 2); - assert (y, [0 0 0 0 0 1 2 3 3 3 3 3 3]); -***** test - u = [-4:0.5:4]; - y = uencode (u, 3, 4); - assert (y, [0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 7]); -***** test - u = [-8:0.5:8]; - y = uencode(u, 4, 8, "unsigned"); - assert (y, [0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 15]); -***** test - u = [-8:0.5:8]; - y = uencode(u, 4, 8, "signed"); - assert (y, [-8 -8 -7 -7 -6 -6 -5 -5 -4 -4 -3 -3 -2 -2 -1 -1 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 7]); -***** error uencode () -***** error uencode (1) -***** error uencode (1, 2, 3, 4, 5) -***** error uencode (1, 100) -***** error uencode (1, 4, 0) -***** error uencode (1, 4, -1) -***** error uencode (1, 4, 2, "invalid") -11 tests, 11 passed, 0 known failure, 0 skipped -[inst/ellip.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/ellip.m -***** demo - [n, Ws] = ellipord ([.1 .2], [.01 .4], 1, 90); - [b, a] = ellip (5, 1, 90, [.1 .2]); - [h, w] = freqz (b, a); - - plot (w./pi, 20*log10 (abs (h)), ";;") - xlabel ("Frequency"); - ylabel ("abs(H[w])[dB]"); - axis ([0, 1, -100, 0]); - - hold ("on"); - x=ones (1, length (h)); - plot (w./pi, x.*-1, ";-1 dB;") - plot (w./pi, x.*-90, ";-90 dB;") - hold ("off"); -***** error [a, b] = ellip () -***** error [a, b] = ellip (1) -***** error [a, b] = ellip (1, 2) -***** error [a, b] = ellip (1, 2, 3) -***** error [a, b] = ellip (1, 2, 3, 4, 5, 6, 7) -***** error [a, b] = ellip (.5, 2, 40, .2) -***** error [a, b] = ellip (3, 2, 40, .2, "invalid") -***** test - ellip (6, 3, 50, .6); - assert (isrow (ans)); -***** test - A = ellip (6, 3, 50, .6); - assert (isrow (A)); -***** test - [A, B] = ellip (6, 3, 50, .6); - assert (isrow (A)); - assert (isrow (B)); -***** test - [z, p, g] = ellip (6, 3, 50, .6); - assert (iscolumn (z)); - assert (iscolumn (p)); - assert (isscalar (g)); -***** test - [a, b, c, d] = ellip (6, 3, 50, .6); - assert (ismatrix (a)); - assert (iscolumn (b)); - assert (isrow (c)); - assert (isscalar (d)); -12 tests, 12 passed, 0 known failure, 0 skipped -[inst/cheby1.m] ->>>>> /build/reproducible-path/octave-signal-1.4.5/inst/cheby1.m -***** error [a, b] = cheby1 () -***** error [a, b] = cheby1 (1) -***** error [a, b] = cheby1 (1, 2) -***** error [a, b] = cheby1 (1, 2, 3, 4, 5, 6) -***** error [a, b] = cheby1 (.5, 2, .2) -***** error [a, b] = cheby1 (3, 2, .2, "invalid") -***** test - cheby1 (3, 4, .5); - assert (isrow (ans)); -***** test - A = cheby1 (3, 4, .5); - assert (isrow (A)); -***** test - [A, B] = cheby1 (3, 4, .5); - assert (isrow (A)); - assert (isrow (B)); -***** test - [z, p, g] = cheby1 (3, 4, .5); - assert (iscolumn (z)); - assert (iscolumn (p)); - assert (isscalar (g)); -***** test - [a, b, c, d] = cheby1 (3, 4, .5); - assert (ismatrix (a)); - assert (iscolumn (b)); - assert (isrow (c)); - assert (isscalar (d)); -11 tests, 11 passed, 0 known failure, 0 skipped -Checking C++ files ... -[src/cl2bp.cc] ->>>>> /build/reproducible-path/octave-signal-1.4.5/src/cl2bp.cc +[src/remez.cc] +>>>>> /build/reproducible-path/octave-signal-1.4.5/src/remez.cc ***** test b = [ - 0.0000000000000000 - 0.0563980420304213 - -0.0000000000000000 - -0.0119990278695041 - -0.0000000000000001 - -0.3016146759510104 - 0.0000000000000001 - 0.5244313235801866 - 0.0000000000000001 - -0.3016146759510104 - -0.0000000000000001 - -0.0119990278695041 - -0.0000000000000000 - 0.0563980420304213 - 0.0000000000000000]; - assert(cl2bp(7, 0.25*pi, 0.75*pi, [0.01, 1.04, 0.01], [-0.01, 0.96, -0.01], 2^11), b, 1e-14); + 0.0415131831103279 + 0.0581639884202646 + -0.0281579212691008 + -0.0535575358002337 + -0.0617245915143180 + 0.0507753178978075 + 0.2079018331396460 + 0.3327160895375440 + 0.3327160895375440 + 0.2079018331396460 + 0.0507753178978075 + -0.0617245915143180 + -0.0535575358002337 + -0.0281579212691008 + 0.0581639884202646 + 0.0415131831103279]; + assert(remez(15,[0,0.3,0.4,1],[1,1,0,0]),b,1e-14); 1 test, 1 passed, 0 known failure, 0 skipped -[src/__fwht__.cc] ->>>>> /build/reproducible-path/octave-signal-1.4.5/src/__fwht__.cc +[src/__ultrwin__.cc] +>>>>> /build/reproducible-path/octave-signal-1.4.5/src/__ultrwin__.cc ***** assert (1) 1 test, 1 passed, 0 known failure, 0 skipped [src/medfilt1.cc] @@ -10348,41 +10398,6 @@ ***** error (medfilt1 ([1 2 3], 1, [], "omitnan", false)); ***** error (medfilt1 ({1 2 3})); 20 tests, 20 passed, 0 known failure, 0 skipped -[src/remez.cc] ->>>>> /build/reproducible-path/octave-signal-1.4.5/src/remez.cc -***** test - b = [ - 0.0415131831103279 - 0.0581639884202646 - -0.0281579212691008 - -0.0535575358002337 - -0.0617245915143180 - 0.0507753178978075 - 0.2079018331396460 - 0.3327160895375440 - 0.3327160895375440 - 0.2079018331396460 - 0.0507753178978075 - -0.0617245915143180 - -0.0535575358002337 - -0.0281579212691008 - 0.0581639884202646 - 0.0415131831103279]; - assert(remez(15,[0,0.3,0.4,1],[1,1,0,0]),b,1e-14); -1 test, 1 passed, 0 known failure, 0 skipped -[src/upfirdn.cc] ->>>>> /build/reproducible-path/octave-signal-1.4.5/src/upfirdn.cc -***** assert (isequal (upfirdn (1:100, 1, 1, 1), 1:100)) -***** assert (isequal (upfirdn (1:100, 1, 1, 2), 1:2:100)) -***** error upfirdn () -***** error upfirdn (1,2) -***** error upfirdn (1,2,3) -***** error upfirdn (1,2,3,4,5) -6 tests, 6 passed, 0 known failure, 0 skipped -[src/__ultrwin__.cc] ->>>>> /build/reproducible-path/octave-signal-1.4.5/src/__ultrwin__.cc -***** assert (1) -1 test, 1 passed, 0 known failure, 0 skipped [src/firpm.cc] >>>>> /build/reproducible-path/octave-signal-1.4.5/src/firpm.cc ***** error firpm (1.1, 2, 3); @@ -10826,6 +10841,27 @@ % Figure shows delay response of (non-linear-phase) % filter designs with progressive fractional-delay. 52 tests, 52 passed, 0 known failure, 0 skipped +[src/cl2bp.cc] +>>>>> /build/reproducible-path/octave-signal-1.4.5/src/cl2bp.cc +***** test + b = [ + 0.0000000000000000 + 0.0563980420304213 + -0.0000000000000000 + -0.0119990278695041 + -0.0000000000000001 + -0.3016146759510104 + 0.0000000000000001 + 0.5244313235801866 + 0.0000000000000001 + -0.3016146759510104 + -0.0000000000000001 + -0.0119990278695041 + -0.0000000000000000 + 0.0563980420304213 + 0.0000000000000000]; + assert(cl2bp(7, 0.25*pi, 0.75*pi, [0.01, 1.04, 0.01], [-0.01, 0.96, -0.01], 2^11), b, 1e-14); +1 test, 1 passed, 0 known failure, 0 skipped Done running the unit tests. Summary: 1021 tests, 1020 passed, 1 known failures, 0 skipped dh_installdocs -O--buildsystem=octave @@ -10851,8 +10887,8 @@ dpkg-gencontrol: warning: package octave-signal: substitution variable ${octave:Upstream-Description} unused, but is defined dh_md5sums -O--buildsystem=octave dh_builddeb -O--buildsystem=octave -dpkg-deb: building package 'octave-signal-dbgsym' in '../octave-signal-dbgsym_1.4.5-2_amd64.deb'. dpkg-deb: building package 'octave-signal' in '../octave-signal_1.4.5-2_amd64.deb'. +dpkg-deb: building package 'octave-signal-dbgsym' in '../octave-signal-dbgsym_1.4.5-2_amd64.deb'. dpkg-genbuildinfo --build=binary -O../octave-signal_1.4.5-2_amd64.buildinfo dpkg-genchanges --build=binary -O../octave-signal_1.4.5-2_amd64.changes dpkg-genchanges: info: binary-only upload (no source code included) @@ -10860,12 +10896,14 @@ dpkg-buildpackage: info: binary-only upload (no source included) dpkg-genchanges: info: not including original source code in upload I: copying local configuration +I: user script /srv/workspace/pbuilder/144433/tmp/hooks/B01_cleanup starting +I: user script /srv/workspace/pbuilder/144433/tmp/hooks/B01_cleanup finished I: unmounting dev/ptmx filesystem I: unmounting dev/pts filesystem I: unmounting dev/shm filesystem I: unmounting proc filesystem I: unmounting sys filesystem I: cleaning the build env -I: removing directory /srv/workspace/pbuilder/2814748 and its subdirectories -I: Current time: Fri May 10 23:19:57 -12 2024 -I: pbuilder-time-stamp: 1715426397 +I: removing directory /srv/workspace/pbuilder/144433 and its subdirectories +I: Current time: Sat Jun 14 07:50:55 +14 2025 +I: pbuilder-time-stamp: 1749837055