【 MATLAB 】進一步瞭解 chirp(未完)
當我直接去看chirp的MATLAB幫助文件時,始終不得要領,查看了很多博文上的說法,也還是不懂,直到我去查看了維基百科,並總結了下面這篇博文後,反過來看chirp的MATLAB幫助文件,才覺得明朗了一些。
因此,推薦看看上篇這篇博文,先從基礎上了解下chirp訊號。
MATLAB 中稱 chirp 為 Swept-frequency cosine,也即掃頻餘弦波。
MATLAB 中給出了 chirp 如下的語法結構:
下面一一簡單介紹:
y = chirp(t,f0,t1,f1) 在陣列t中定義的時間例項中產生線性掃頻餘弦訊號的樣本,f0為時間為0時刻的瞬時頻率,f1為時刻t1時的瞬時頻率,二者單位都是赫茲。如果未指定,則對於logarithmic chirp,f0為10^-6;對於其他的chirp,f0都為0,t1為1,f1為100.
y = chirp(t,f0,t1,f1,
指定可選擇的掃頻方法,掃頻方法介紹如下:'method'
)
如果看了上篇博文,這點介紹應該是能看懂的(儘管有些差異,差異在於叫法以及少了下面的第二種情況),我就不翻譯了,翻譯也許就沒那麼精妙了。
總結起來,掃頻方法分為三種,分別為linear、quadratic、logarithmic。
y = chirp(t,f0,t1,f1,
allows an initial phase 'method'
,phi)phi
to be specified in degrees. If unspecified, phi
is 0
. Default values are substituted for empty or omitted trailing input arguments.
這種形式指定了初始相位,如果未指定初始相位為0。
y = chirp(t,f0,t1,f1,'quadratic',phi,
specifies the 'shape'
)shape
of the quadratic swept-frequency signal's spectrogram. shape
is either concave
or convex
, which describes the shape of the parabola in the positive frequency axis. If shape
is omitted, the default is convex for downsweep (f
y = chirp(t,f0,t1,f1,'quadratic',phi,'shape')指定二次掃頻訊號的頻譜圖的形狀。 形狀是凹形或凸形,它描述了正頻率軸上拋物線的形狀。 如果省略形狀,則預設為下掃頻(f0> f1)為凸,而上掃頻(f0 <f1)為凹。
下面舉一個例子:
Linear chirp
Generate a chirp with linear instantaneous frequency deviation. The chirp is sampled at 1 kHz for 2 seconds. The instantaneous frequency is 0 at t = 0 and crosses 250 Hz at t = 1 second.
產生具有線性瞬時頻率偏差的chirp。取樣率為1KHz,時間為2s,初始頻率為0,時間為1時刻的頻率為250Hz。
% Generate a chirp with linear instantaneous frequency deviation.
% The chirp is sampled at 1 kHz for 2 seconds.
% The instantaneous frequency is 0 at t = 0 and crosses 250 Hz at t = 1 second.
clc
clear
close all
t = 0:1/1e3:2;
y = chirp(t,0,1,250);
subplot(2,1,1)
plot(t,y)
subplot(2,1,2)
spectrogram(y,256,250,256,1e3,'yaxis')
Quadratic chirp
Generate a chirp with quadratic instantaneous frequency deviation. The chirp is sampled at 1 kHz for 2 seconds. The instantaneous frequency is 100 Hz at t = 0 and crosses 200 Hz at t = 1 second.
% Generate a chirp with quadratic instantaneous frequency deviation.
% The chirp is sampled at 1 kHz for 2 seconds.
% The instantaneous frequency is 100 Hz at t = 0 and crosses 200 Hz at t = 1 second.
clc
clear
close all
t = 0:1/1e3:2;
y = chirp(t,100,1,200,'quadratic ');
subplot(2,1,1)
plot(t,y)
% Compute and plot the spectrogram of the chirp.
% Specify 128 DFT points, a Hamming window of the same length, and 120 samples of overlap.
subplot(2,1,2)
spectrogram(y,256,250,256,1e3,'yaxis')
中間流了兩種情況,等我弄明白了再填。
那個spectrogram我會單獨寫一篇部落格,弄懂它。暫時還不是太明白原理。
Logarithmic Chirp
% Generate a logarithmic chirp sampled at 1 kHz for 10 seconds.
% The instantaneous frequency is 10 Hz initially and 400 Hz at the end.
clc
clear
close all
t = 0:1/1e3:10;
fo = 10;
f1 = 400;
y = chirp(t,fo,10,f1,'logarithmic');
subplot(2,1,1)
plot(t,y)
% Compute and plot the spectrogram of the chirp.
% Specify 256 DFT points, a Hamming window of the same length, and 200 samples of overlap.
subplot(2,1,2)
spectrogram(y,256,200,256,1e3,'yaxis')