2016/10/29

Sinc Function / Sampling Function 取樣函數

There are two definitions for the Sinc function:

When x ≠ 0,

for mathematics,

    sinc(x) = sin(x)/(unnormalized sinc function)

for digital signal processing,

    sinc(x) = sin(πx)/πx (normalized sinc function)

When x = 0,

    sinc(x) = sinc(0) = 1 for both mathematics and DSP.

In DSP, sinc(x) is also called the sampling function:

    Sa(πx) = sin(πx)/πx = sinc(x)

Euler's formula 歐拉公式

Leonhard Euler (1707-1783) 瑞士數學家
Euler 歐拉/尤拉

Euler's formula helps to find the exponential function of a complex number.

Euler's formula 歐拉公式:

ejx = cosx + isinx = cisx

Therefore,

e = cosθ + isinθ (1)
e-iθ = cos(-θ) + isin(-θ) = cosθ - isinθ (2)

(1) + (2) gives
=> e + e-iθ =  2cosθ
=> cosθ = ( e + e-iθ )/2

(1) - (2) gives
=> e - e-jθ = 2isinθ
=> sinθ = ( e - e-iθ )/2i

cosθ = Re(e) =( e + e-iθ )/2
sinθ = Im(e) =( e - e-iθ )/2i

Example:

ei = cos(1) + isin(1) = 0.540302306 + 0.841470985i
e = cos(π) + isin(π) = -1 => e + 1 = 0

Matlab function:
exp(i*pi) or exp(j*pi)

參考資料

cis (mathematics) (Wikipedia)
Relations between cosine, sine and exponential functions
Exponential function & natural logarithm 指數函數與自然對數
Magnitude of Exponential Function exp() = ? 如何求exp()的大小/絕對值

2016/10/26

Summation and Multiplication symbols 求和符號、乘積符號

summation 求和符號:

Σ - uppercase Sigma

multiplication 乘積符號:

Π - uppercase Pi

相關資料

數學符號表

Exponential Function & Natural Logarithm 指數函數與自然對數

exp(x) = ex

some coordinates:

(0, 1)
(1, e)

Differentiation 微分 :
d(ex)/dx = ex
d(eax)/dx = aeax


Integration 積分 :

∫ ex dx = ex + c
∫ eax dx = (1/a)eax + c

Maclaurin Series:

ex = 1 + x + x2/2! + x3/3! + ... + xn/n!

ea+b = eaeb
(ea)b = eab
ea+bi = eaebi = ea(cosb + isinb) = eacis(b) (Euler's formula)

Inverse of ex:
ln(x)

natural logarithm 自然對數
loge(x) = ln(x)

derivative 導數:
d[ln(x)]/dx = 1/x

Exponential Function plotted by Matlab:



相關資料

Exponential Function (Wikipedia)
Matlab: Draw an Exponential Function with exp() with a custom Y-axis at x = 0

2016/10/25

DSP terms 數位訊號處理基本名詞

digital signal processing 數位訊號處理/數位信號處理

sampling 取樣
quantization 量化
reconstruction 重建

point sampling 點取樣
impulse sampling 脈衝取樣

aliasing 頻疊、混疊
Nyquist frequency 奈奎斯特頻率

zero crossing 零交叉 - 訊號剛好為零(由負到正或由正到負的瞬間) (Wikipedia)
根據Wikipedia,計算zero crossing的數量可估計語音的fundamental frequency基頻

piecewise 分段
piecewise linear function 分段線性函數

sample and hold 取樣與保持
linear interpolation 線性內插

quantization step 量化間距/量化步階
quantization error 量化誤差

Signal-to-quantization-noise ratio (SQNR) 信號-量化雜訊比
SQNR = 6.02b + 1.76 dB 量化時每增加一個bit時,SQNR可提升6.02 dB (See Signal to quantization noise in quantized sinusoidal)

unit impulse 單位脈衝 δ[n] Dirac delta function 狄拉克δ函數
unit step 單位步階/單位階 u[n]

companding 壓擴/壓伸

time domain 時域
frequency domain 頻域
complex frequency domain 複數頻域

Fourier series 傅立葉級數
discrete Fourier transform (DFT) 離散傅立葉變換
fast Fourier transform (FFT) 快速傅立葉變換

discrete Cosine transform (DFT) 離散餘弦轉換

Z-transform Z 轉換
region of convergence (ROC) 收斂域

參考資料

國家教育研究院雙語詞彙、學術名詞暨辭書資訊網

課程
DeltaMOOCx

2016/10/24

Matlab: Draw a Sine curve with sind()

To plot a sine wave between 0° and 360° in Matlab, simply use sind() in degrees:

>> x = 0:360;
>> y = sind(x);
>> plot(x,y)

Result:



If you want to draw sine waves in radians, use sin() instead. The website below shows how to use the sin() function and how to adjust axis ranges:

Set axis limits and aspect ratio (MathWorks)

You may also try the code below:

>> s = [0:.1:2*pi];
>> y = sin(s);
>> plot(s,y)

Related Information:
How to draw a sine wave with Simulink

2016/10/18

Complex Number & Complex Conjugate 複數、共軛複數

complex number 複數
complex plane 複數平面
real part 實部
imaginary part 虛部

z = a + bi
Re(z) = a
Im(z) = b
i2 = -1
-i = 1/i proof: -i = -i × i/i = -i2/i =-(-1)/i = 1/i
∠z = tan-1(Im(z)/Re(z)) = tan-1(Ib/a)

z = rθ
r is modulus 模數 / magnitude 量值/大小
θ is argument 幅角/引數 / phase 相位/相角
r = |z|

argument 幅角
phase 相位/相角
in-phase 同相位
out-of-phase 不同相位
For Acos(ax + b), phase is b. and amplitude is A.

radian 徑度/弧度

phasor 相量

ejx = cosx + isinx = cisx     (Euler's formula)

complex conjugate 共軛複數
if z = a + bi,
the complex conjugate of z is
z_bar or z* = a - bi
Re(z*) = Re(z) = a
Im(z*) = -Im(z) = -b

To get z*, simply flip z around x-axis.

|z| = | a + bi | = √(a2 + b2)
|z|2 = |a + bi|2 = a2 + b2 = (a + bi )(a - bi ) = (z)(z*)

Matlab: conj()

>> z = 1 + 2i

z =
   1.0000 + 2.0000i

>> z_conj = conj(z)

z_conj =

   1.0000 - 2.0000i

conjugate transpose 共軛轉置

相關資料

Euler's formula

2016/10/07

Matlab: Vector, Matrix, Array and Row/Column Vector

In Matlab,

vector = one-dimensional array
matrix = two-dimensional array

The example below shows the difference between a row vector and a column vector:

>> x = 1:7

x =

     1     2     3     4     5     6     7

>> y = x'

y =

     1
     2
     3
     4
     5
     6
     7

where

x is a row vector.
y is a column vector.

Matlab: Submatrix/Subvector

A. The example below shows how to:

1. Define a vector with incrementing integers.
2. Define a second vector (subvector) which is formed from partial elements of the first vector.

>> a = 1:10

a =

     1     2     3     4     5     6     7     8     9    10

>> b = a(5:7)

b =

     5     6     7

B. The example below shows how to get a submatrix from an existing matrix:

c =

     1     2     3
     4     5     6
     7     8     9

>> d = c(2:3,2:3)

d =

     5     6
     8     9

C. Divide all elements of a vector by an integer:

>> e = a/2

e =

    0.5000    1.0000    1.5000    2.0000    2.5000    3.0000    3.5000    4.0000    4.5000    5.0000

C語言:檢查字元是否為英文字母 - isalpha()

To use function isalpha(), call

#include <ctype.h>

char ch;

...

if (isalpha(ch)) {
    //ch is an alphabet
} else {
    //ch is not an alphbet
}

Matlab: 儲存變數於MAT檔案中 Store Variables in MAT-files

PC

To store Matlab variables, select:

File -> Save Workspace As -> *.mat

To retrieve variables stored in a MAT-file, select:

File -> Open -> *.mat

Mac

Click the "Save Workspace" button or press the hotkey:

[command] + [s]


Matlab: 檢查是否已安裝工具箱 Check if Matlab Image Processing Toolbox already Installed

To check whether the Image Processing Toolbox has already been installed in Matlab, simply type:

help images

Companding 壓擴/壓伸

companding 壓擴/壓伸 = compressing 壓縮 + expanding 擴展

companded quantization = compressor + uniform quantizer 均勻量化 + expander

where

compressor 和 expander 的功能相反

目的:
當dynamic range有限時,透過先壓縮再還原,以減輕失真

在電話等語音通訊中,fricative擦音/磨擦音會因能量較低而無法被有效地量化
透過companding,可使這些語音細節得到較妥善地量化,進而有較好的效果

Companding algorithms of the G.711 ITU-T standard:
μ-law - USA/Japan - 動態範圍(dynamic range)較大,訊號弱時失真(distortion)較大
A-law - Europe - 訊號弱時音質較好

G.711支援A-law以及μ-law兩種編碼方式

Reference

Difference Between A-law and u-Law
G.711 (維基百科)