Utility Functions Octave Codes (0A) Young Won Lim 1/24/18

Similar documents
Digital Signal Octave Codes (0A)

Digital Signal Octave Codes (0A)

Fourier Analysis Overview (0A)

Digital Signal Octave Codes (0A)

Digital Signal Octave Codes (0A)

Digital Signal Octave Codes (0A)

Digital Signal Octave Codes (0A)

Fourier Analysis Overview (0A)

DFT Frequency (9A) Each Row of the DFT Matrix. Young Won Lim 7/31/10

Fourier Analysis Overview (0B)

Signal Functions (0B)

General CORDIC Description (1A)

CT Rectangular Function Pairs (5B)

Discrete Time Rect Function(4B)

Discrete Time Rect Function(4B)

FFT Octave Codes (1B) Young Won Lim 7/6/17

Capacitor in an AC circuit

DFT Octave Codes (0B) Young Won Lim 4/15/17

Capacitor Young Won Lim 06/22/2017

Down-Sampling (4B) Young Won Lim 10/25/12

Up-Sampling (5B) Young Won Lim 11/15/12

Relations (3A) Young Won Lim 3/27/18

Down-Sampling (4B) Young Won Lim 11/15/12

Bandpass Sampling (2B) Young Won Lim 3/27/12

Audio Signal Generation. Young Won Lim 1/29/18

Audio Signal Generation. Young Won Lim 2/2/18

Undersampling (2B) Young Won Lim 4/4/12

Capacitor in an AC circuit

Capacitor in an AC circuit

CLTI System Response (4A) Young Won Lim 4/11/15

Audio Signal Generation. Young Won Lim 2/2/18

Capacitor and Inductor

Capacitor and Inductor

Expected Value (10D) Young Won Lim 6/12/17

Capacitor in an AC circuit

Phasor Young Won Lim 05/19/2015

Capacitor in an AC circuit

Capacitor in an AC circuit

Background LTI Systems (4A) Young Won Lim 4/20/15

Group & Phase Velocities (2A)

Capacitor in an AC circuit

Group Delay and Phase Delay (1A) Young Won Lim 7/19/12

Capacitors in an AC circuit

The Growth of Functions (2A) Young Won Lim 4/6/18

Higher Order ODE's (3A) Young Won Lim 7/7/14

Propagating Wave (1B)

Higher Order ODE's (3A) Young Won Lim 12/27/15

CLTI Differential Equations (3A) Young Won Lim 6/4/15

Root Locus (2A) Young Won Lim 10/15/14

Spectra (2A) Young Won Lim 11/8/12

Matrix Transformation (2A) Young Won Lim 11/10/12

Hilbert Inner Product Space (2B) Young Won Lim 2/7/12

Propositional Logic Resolution (6A) Young W. Lim 12/12/16

Background Trigonmetry (2A) Young Won Lim 5/5/15

Group Velocity and Phase Velocity (1A) Young Won Lim 5/26/12

Line Integrals (4A) Line Integral Path Independence. Young Won Lim 10/22/12

Propositional Logic Resolution (6A) Young W. Lim 12/31/16

Hamiltonian Cycle (3A) Young Won Lim 5/5/18

Higher Order ODE's (3A) Young Won Lim 7/8/14

CT Correlation (2A) Young Won Lim 9/9/14

Introduction to ODE's (0A) Young Won Lim 3/9/15

Differentiation Rules (2A) Young Won Lim 1/30/16

Implication (6A) Young Won Lim 3/17/18

Detect Sensor (6B) Eddy Current Sensor. Young Won Lim 11/19/09

General Vector Space (2A) Young Won Lim 11/4/12

Bayes Theorem (4A) Young Won Lim 3/5/18

ODE Background: Differential (1A) Young Won Lim 12/29/15

Complex Series (3A) Young Won Lim 8/17/13

Matrix Transformation (2A) Young Won Lim 11/9/12

Dispersion (3A) 1-D Dispersion. Young W. Lim 10/15/13

FSM Examples. Young Won Lim 11/6/15

Definitions of the Laplace Transform (1A) Young Won Lim 1/31/15

Separable Equations (1A) Young Won Lim 3/24/15

Complex Trigonometric and Hyperbolic Functions (7A)

Magnetic Sensor (3B) Magnetism Hall Effect AMR Effect GMR Effect. Young Won Lim 9/23/09

Resolution (7A) Young Won Lim 4/21/18

Sequential Circuit Timing. Young Won Lim 11/6/15

Line Integrals (4A) Line Integral Path Independence. Young Won Lim 11/2/12

Signal Processing. Young Won Lim 2/20/18

Signal Processing. Young Won Lim 2/22/18

Bayes Theorem (10B) Young Won Lim 6/3/17

Differentiation Rules (2A) Young Won Lim 2/22/16

Propositional Logic Logical Implication (4A) Young W. Lim 4/11/17

Complex Functions (1A) Young Won Lim 2/22/14

Higher Order ODE's, (3A)

Implication (6A) Young Won Lim 3/12/18

Finite State Machine (1A) Young Won Lim 6/9/18

Linear Equations with Constant Coefficients (2A) Young Won Lim 4/13/15

General Vector Space (3A) Young Won Lim 11/19/12

Propositional Logic Logical Implication (4A) Young W. Lim 4/21/17

Signals and Spectra (1A) Young Won Lim 11/26/12

Surface Integrals (6A)

Propositional Logic Arguments (5A) Young W. Lim 11/30/16

First Order Logic Implication (4A) Young W. Lim 4/6/17

Logic Background (1A) Young W. Lim 5/14/18

Background ODEs (2A) Young Won Lim 3/7/15

Introduction to ODE's (0P) Young Won Lim 12/27/14

Propositional Logic Arguments (5A) Young W. Lim 10/11/16

Probability (10A) Young Won Lim 6/12/17

Second Order ODE's (2A) Young Won Lim 5/5/15

Transcription:

Copyright (c) 2009-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Please send corrections (or suggestions) to youngwlim@hotmail.com. This document was produced by using LibreOffice and Octave.

Based on M.J. Roberts, Fundamentals of Signals and Systems 3

Singularity Functions Continuous Time u(t) ramp(t) rect(t) tri(t) drcl(t) 4

u(t), ramp(t), rect(t), tri(t) # Prevent Octave from thinking that this # is a function file: 1; function y = u(t) zro = t == 0; pos = t > 0; y = zro/2 + pos; function y = ramp(t) y = t.*(t >= 0); function y = rect(t) y = u(t+0.5) u(t-0.5); function y = tri(t) y = ramp(t+1) 2*ramp(t) + ramp(t-1); 5

u(t) function y = u(t) zro = t == 0; pos = t > 0; y = zro/2 + pos; t > 0 : zro=0, pos=1 y=1 t = 0 : zro=1, pos=0 y=0.5 t < 0 : zro=0, pos=0 y=0 6

ramp(t) function y = ramp(t) y = t.*(t >= 0); (t>=0) t > 0 : 1.* t t t = 0 : 1.* t t t < 0 : 0.* t 0 7

rect(t) function y = rect(t) y = u(t+0.5) u(t-0.5); t+0.5 > 0 : u(t+0.5) = 1 t+0.5 = 0 : u(t+0.5) = 0.5 t+0.5 < 0 : u(t+0.5) = 0 t-0.5 > 0 : u(t-0.5) = 1 t-0.5 = 0 : u(t-0.5) = 0.5 t-0.5 < 0 : u(t-0.5) = 0 t > +0.5 : rect(t) = 0 t = +0.5 : rect(t) = 0.5-0.5 < t < +0.5 : rect(t) = 1 t = -0.5 : rect(t) = 0.5 t < -0.5 : rect(t) = 0 8

u(t), ramp(t), rect(t), tri(t) function y = tri(t) y = ramp(t+1) 2*ramp(t) + ramp(t-1); 9

find( ) >> t = -5:+5 t = -5-4 -3-2 -1 0 1 2 3 4 5 >> find(t==t) ans = 1 2 3 4 5 6 7 8 9 10 11 index >> find(mod(t,2)) ans = 1 3 5 7 9 11 10

drcl(t,n) function x = drcl(t,n) num = sin(n*pi*t); den = N*sin(pi*t); I = find(abs(den) < 100*eps); num(i) = cos(n*pi*t(i)); den(i) = cos(pi*t(i)); x = num./ den ; f (t ) = sin(n π t) N sin(π t) f (0) = lim t 0 sin(n π t ) N sin(π t ) = lim t 0 N π cos(n π t ) N π cos(π t) = lim t 0 cos(n π t ) cos(πt) 100*eps = 2.2204e-14 : values very close to zero 11

The function eps eps is the relative spacing between any two adjacent numbers in the machine s floating point system. system dependent IEEE floating point arithmetic eps is approximately 2.2204e-16 for double precision 1.1921e-07 for single precision. eps return a scalar with the value eps (1.0). eps(x) return the distance between x and the next larger value. eps(n,m, k,...) matrix dimensions eps(..., double ) eps(..., single ) 12

The function eps(x) >> num2hex(1) ans = 3ff0000000000000 >> num2hex(1+eps(1)) ans = 3ff0000000000001 >> num2hex(eps(1)) ans = 3cb0000000000000 >> >> hex2dec("3cb")-1023 ans = -52 >> num2hex(10) ans = 4024000000000000 >> num2hex(10+eps(10)) ans = 4024000000000001 >> num2hex(eps(10)) ans = 3ce0000000000000 >> >> hex2dec("3ce")-1023 ans = -49 1*eps 8*eps https://en.wikipedia.org/wiki/double-precision_floating-point_format 13

Testing CT Singularity Functions t = -10:0.1:+10; subplot(5, 1, 1); plot(t, u(t)); ylabel('u(t)'); subplot(5, 1, 2); plot(t, ramp(t)); ylabel('ramp(t)'); subplot(5, 1, 3); plot(t, rect(t)); ylabel('rect(t)'); subplot(5, 1, 4); plot(t, tri(t)); ylabel('tri(t)'); subplot(5, 1, 5); plot(t, drcl(t, 2)); ylabel('drcl(t,2)'); 14

Test Results for CT Singularity Functions 15

Singularity Functions Discrete Time impd(n) ud(n) rampd(n) rectd(w,n) impnd(n,n) 16

impd(n), ud(n), rampd(n) # Prevent Octave from thinking that this # is a function file: 1; function y = impd(n) y = double(n == 0); ss = find(round(n) ~= n); y(ss) = NaN; function y = ud(n) y = double(n >= 0); ss = find(round(n) ~= n); y(ss) = NaN; function y = rampd(n) pos = double(n>0); y = n.*pos; ss = find(round(n) ~= n); y(ss) = NaN; 17

rectd(w,n), impnd(n,n) function y = rectd(w,n); if (W == round(w)) y = double(abs(n) <= abs(w)); ss = find(round(n) ~= n); y(ss) = NaN; else disp('in rectd, width paraemter, W, is not an integer'); endif function y = impnd(n, n) if (N == round(n)) y = double(n/n == round(n/n)); ss = find(round(n) ~= n); y(ss) = NaN; else disp('in impnd, period paraemter, N, is not an integer'); endif 18

impd(n) function y = impd(n) y = double(n == 0); ss = find(round(n) ~= n); y(ss) = NaN; n = -1 (n==0) 0 double 0. round(n)=-1 n = 0 (n==0) 1 double 1. round(n)= 0 n = +1 (n==0) 0 double 0. round(n)=+1 n = +1.5 (n==0) 0 NaN round(n)=+1 19

ud(n) function y = ud(n) y = double(n >= 0); ss = find(round(n) ~= n); y(ss) = NaN; n = -1 (n>=0) 0 double 0. round(n)=-1 n = 0 (n>=0) 1 double 1. round(n)= 0 n = +1 (n>=0) 1 double 1. round(n)=+1 n = +1.5 (n>=0) 1 NaN round(n)=+1 20

rampd(n) function y = rampd(n) pos = double(n>0); y = n.*pos; ss = find(round(n) ~= n); y(ss) = NaN; n = -1 (n>0) 0 n * double 0. round(n)=-1 n = 0 (n>0) 0 n * double 0. round(n)= 0 n = +1 (n>0) 1 n * double 1. round(n)=+1 n = +1.5 (n>0) 1 NaN round(n)=+1 21

rectd(w,n) function y = rectd(w,n); if (W == round(w)) y = double(abs(n) <= abs(w)); ss = find(round(n) ~= n); y(ss) = NaN; else disp('width paraemter W is not an integer'); endif n = -2 abs(n) 2 abs(w) 1 double 0. round(n)=-2 n = -1 abs(n) 1 abs(w) 1 double 1. round(n)=-1 n = 0 abs(n) 0 abs(w) 1 double 1. round(n)= 0 n = +1 abs(n) 1 abs(w) 1 double 1. round(n)=+1 n = +2 abs(n) 2 abs(w) 1 double 0. round(n)=+2 n = +1.5 abs(n)1.5 abs(w) 1 NaN round(n)=+1 22

impnd(n,n) function y = impnd(n, n) if (N == round(n)) --------------------- integer N y = double(n/n == round(n/n)); ------- integer (n/n) ss = find(round(n) ~= n); y(ss) = NaN; else disp('period paraemter N is not an integer'); endif y becomes 1.0 when n is integer multiple of N Otherwise y is 0.0 (n = kn) 23

rectd(3,n) and impnd(3,n) rectd(3, n) W=3 W=3 impnd(3, n) N=3 N=3 24

Testing DT Singularity Functions n = -10: 10; subplot(5, 1, 1); stem(n, impd(n)); ylabel('impd(n)'); subplot(5, 1, 2); stem(n, ud(n)); ylabel('ud(n)'); subplot(5, 1, 3); stem(n, rampd(n)); ylabel('rampd(n)'); subplot(5, 1, 4); stem(n, rectd(5, n)); ylabel('rectd(5,n)'); subplot(5, 1, 5); stem(n, impnd(5, n)); ylabel('impnd(5,n)'); 25

Test Results for DT Singular Functions 26

References [1] http://en.wikipedia.org/ [2] J.H. McClellan, et al., Signal Processing First, Pearson Prentice Hall, 2003 [3] M.J. Roberts, Fundamentals of Signals and Systems [4] S.J. Orfanidis, Introduction to Signal Processing [5] K. Shin, et al., Fundamentals of Signal Processing for Sound and Vibration Engineerings [6] A graphical interpretation of the DFT and FFT, by Steve Mann 27