2017/10/25

filter 濾波器

low-pass 低通
high-pass 高通
band-pass 帶通
band-stop 帶止/帶阻

passband 通帶/通頻帶
stopband 止帶/阻帶/抑制帶
transition band 過度帶/過渡頻帶

cutoff frequency 截止頻率

ripple 漣波

Matlab Filter Tools:

filterDesigner, sptool

2017/10/23

Matlab: Play an audio file with a directory

To play a sound file e.g. a wav file in a folder, type the following commands:

>> [y,Fs]= audioread('MyFolder/song.wav'); %Use slash for both Windows and Mac. Backslash works with Windows only.
>> sound(y,Fs);

2017/10/21

Matlab: Save and load variables/matrices in MAT file

To store and then read variables/matrices with Matlab, use the save and load commands with a *.mat file.
Example:

>> var1 = 1;
>> var2 = 2;
>> save var.mat var1 var2
>> clear
>> load var.mat


Related Information:

Matlab: Clear Commands (Study EECC)

2017/10/12

Fundamental Frequency, Harmonic and Overtone 基頻、諧波、泛音

Fundamental Frequency 基本頻率/基頻
Fundamental Tone 基音/根音
Harmonic 諧波/諧音
Harmonic series 諧波列/泛音列
Overtone 泛音

Standing Wave 駐波
Periodic Tone 週期音
Pure Tone 純音
Complex Tone 複合音/複音
Higher Harmonics 高次諧波 (f×2, f×3...)

Partial 分音 - 出現於complex tone中,不一定是F0的integer multiple的sine wave

Example of a harmonic series:

f = fundamental frequency / fundamental tone / 1st harmonic 第一諧音/波
f×2 = 1st overtone 第一泛音 / 2nd harmonic 第二諧音/波
f×3 = 2nd overtone 第二泛音 / 3rd harmonic 第三諧音/波

參考資料

Harmonic (Wikipedia)
駐波(standing waves)(小小整理網站)
Harmonics (諧波)、Overtones (泛音)、Partials (分音)
Fourier Analysis Terms 傅立葉分析相關名詞

2017/10/04

Matlab: Unit Impulse δ[n] 單位脈衝函數

The unit impulse, or the Dirac delta function, has zero values for all input values except a value of one at zero.

To plot the unit impulse function δ[n], type the Matlab code below:

>> t = -10:10;
>> s = (t==0); %s is one only when t equals 0
>> stem(t,s)

Result:



For δ[n-2], the Matlab code is

>> t = -10:10;
>> s2 = (t==2); %s is one when t equals 2
>> stem(t,s2)

Result:


Reference:

2017/09/30

Matlab: Plot multiple curves with legend

Example 1: Draw sin(x), sin(x/2) and sin(x)+sin(x/2)

>> x = 0:360;
>> y1 = sind(x);
>> y2 = sind(x/2);
>> y3 = y1+y2;
>> plot(x, y1, x, y2, x, y3);
>> legend('sin(x)','sin(x/2)','sin(x)+sin(x/2)')

Result:



Example 2: Draw log(x), log2(x), log10(x)

>> x = 0:0.01:5;
>> y1 = log(x);
>> y2 = log2(x);
>> y3 = log10(x);
>> plot(x, y1, x, y2, x, y3)
>> legend('log(x)','log2(x)','log10(x)')

Result:


Example 3: 3e-0.25*tsin(5t)

>> t = 0:0.01:30;
>> x1 = 3*exp(-0.25*t).*sin(5*t);
>> x2 = 0.2*cos(2*t);
>> x3 = 3*exp(-0.25*t).*sin(5*t)+0.2*cos(2*t);
>> plot(t,x1,t,x2,t,x3);
>> legend('x1','x2','x3');

Result:



Related Information:

Draw an Exponential Function with exp() with a custom Y-axis at x = 0
Exponential Function & Natural Logarithm 指數函數與自然對數

2017/09/28

Matlab: Hello GUI with guide

To draw a window or the graphical user interface (GUI) with Matlab, type:

>> guide

Select Blank GUI (Default):


A window for GUI design is displayed:



Draw something such as a "Hello World!" static text and some buttons.


Save the design figure as your preferred name, e.g. gui_layout.fig



A corresponding m file such as gui_layout.m is automatically created.


In the Command Window, type the name of the m-file e.g. type gui_layout and the window designed previously is displayed.