Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

信号の生成と可視化

この例では、Signal Processing Toolbox™ で利用可能な関数を使用して、広く利用されている周期的/非周期的波形、スイープ周波数正弦波、およびパルス列を生成する方法を示します。

周期的な波形

MATLAB® の関数sincos以外にも、Signal Processing Toolbox™ には、sawtoothsquare など、周期的な信号を生成する関数が用意されています。

関数sawtoothは、±1 にピークをもつ、周期が 2π のノコギリ波を生成します。オプションの幅パラメーターは、信号が最大となる 2π の非整数倍数を指定します。

関数squareは周期が 2π の矩形波を生成します。オプションのパラメーターは、信号が正となるサイクルの割合であるデューティ比を指定します。

10 kHz のサンプル レートをもつ 50 Hz のノコギリ波を 1.5 秒間生成します。矩形波についても同じく計算します。

fs = 10000;
t = 0:1/fs:1.5;
x1 = sawtooth(2*pi*50*t);
x2 = square(2*pi*50*t);

nexttile
plot(t,x1)
axis([0 0.2 -1.2 1.2])
xlabel("Time (sec)")
ylabel("Amplitude") 
title("Sawtooth Periodic Wave")

nexttile
plot(t,x2)
axis([0 0.2 -1.2 1.2])
xlabel("Time (sec)")
ylabel("Amplitude")
title("Square Periodic Wave")

Figure contains 2 axes objects. Axes object 1 with title Sawtooth Periodic Wave, xlabel Time (sec), ylabel Amplitude contains an object of type line. Axes object 2 with title Square Periodic Wave, xlabel Time (sec), ylabel Amplitude contains an object of type line.

非周期的な波形

三角パルス、矩形パルス、およびガウス パルスを生成するには、ツールボックスの関数 tripulsrectpuls、および gauspuls を使用します。

関数tripulsは、サンプリングされた単位高さの非周期の三角パルスを、t = 0 付近を中心として既定の幅 1 で生成します。

関数rectpulsは、サンプリングされた単位高さの非周期の矩形パルスを、t = 0 付近を中心として既定の幅 1 で生成します。非ゼロ振幅の区間は、右側でオープンになるように定義されます。つまり、rectpuls(0.5) = 0 では rectpuls(-0.5) = 1 です。

10 kHz のサンプル レートおよび 20 ms の幅をもつ三角パルスを 2 秒間生成します。矩形パルスについても同じく計算します。

fs = 10000;
t = -1:1/fs:1;
x1 = tripuls(t,20e-3);
x2 = rectpuls(t,20e-3);

figure
nexttile
plot(t,x1)
axis([-0.1 0.1 -0.2 1.2])
xlabel("Time (sec)")
ylabel("Amplitude")
title("Triangular Aperiodic Pulse")

nexttile
plot(t,x2)
axis([-0.1 0.1 -0.2 1.2])
xlabel("Time (sec)")
ylabel("Amplitude")
title("Rectangular Aperiodic Pulse")

Figure contains 2 axes objects. Axes object 1 with title Triangular Aperiodic Pulse, xlabel Time (sec), ylabel Amplitude contains an object of type line. Axes object 2 with title Rectangular Aperiodic Pulse, xlabel Time (sec), ylabel Amplitude contains an object of type line.

関数gauspulsは、指定した時間、中心周波数および比帯域幅のガウス変調正弦波パルスを生成します。

関数sincは、入力ベクトルや入力行列に対し数学 sinc 関数を計算します。sinc 関数は、幅 2π と単位高さの矩形パルスの連続逆フーリエ変換です。

1 MHz のサンプル レートで、60% の帯域幅をもつ 50 kHz のガウス RF パルスを生成します。包絡線がピークから 40 dB 減衰するところでパルスを打ち切ります。

tc = gauspuls("cutoff",50e3,0.6,[],-40); 
t1 = -tc : 1e-6 : tc; 
y1 = gauspuls(t1,50e3,0.6);

線形に配置されたベクトルの sinc 関数を生成します。

t2 = linspace(-5,5);
y2 = sinc(t2);

figure
nexttile
plot(t1*1e3,y1)
xlabel("Time (ms)")
ylabel("Amplitude")
title("Gaussian Pulse")

nexttile
plot(t2,y2)
xlabel("Time (sec)")
ylabel("Amplitude")
title("Sinc Function")

Figure contains 2 axes objects. Axes object 1 with title Gaussian Pulse, xlabel Time (ms), ylabel Amplitude contains an object of type line. Axes object 2 with title Sinc Function, xlabel Time (sec), ylabel Amplitude contains an object of type line.

スイープ周波数波形

ツールボックスの関数を使用して、関数chirpなどのスイープ周波数波形を生成することもできます。2 つのオプションのパラメーターは、別のスイープ メソッドと初期位相 (単位: degree) を指定します。以下の例では、関数 chirp を使用して、線形または 2 次の凸および凹、2 次チャープを生成します。

1 kHz で 2 秒間サンプリングされた線形チャープを生成します。瞬時周波数は、t = 0 では 100 Hz であり、t = 1 秒で 250 Hz になります。

tlin = 0:0.001:2;
ylin = chirp(tlin,100,1,250);

1 kHz で 4 秒間サンプリングされた 2 次チャープを生成します。瞬時周波数は、t = 0 では 100 Hz であり、t = 1 秒で 200 Hz になります。

tq = -2:0.001:2;
yq = chirp(tq,100,1,200,"quadratic");

チャープのスペクトログラムを計算して表示します。

figure
nexttile
pspectrum(ylin,tlin,"spectrogram", ...
    Leakage=0.85,TimeResolution=0.1,OverlapPercent=99)
title("Linear Chirp")

nexttile
pspectrum(yq,tq,"spectrogram", ...
    Leakage=0.85,TimeResolution=0.1,OverlapPercent=99)
title("Quadratic Chirp")

Figure contains 2 axes objects. Axes object 1 with title Linear Chirp, xlabel Time (s), ylabel Frequency (Hz) contains an object of type image. Axes object 2 with title Quadratic Chirp, xlabel Time (s), ylabel Frequency (Hz) contains an object of type image.

1 kHz で 2 秒間サンプリングされた凸の 2 次チャープを生成します。瞬時周波数は、t = 0 では 100 Hz であり、t = 1 秒で 400 Hz に増加します。

tcx = -1:0.001:1;
fo = 100;
f1 = 400;
ycx = chirp(tcx,fo,1,f1,"quadratic",[],"convex");

1 kHz で 2 秒間サンプリングされた凹の 2 次チャープを生成します。瞬時周波数は、t = 0 では 400 Hz であり、t = 1 秒で 100 Hz に減少します。

tcv = -1:0.001:1;
fo = 400;
f1 = 100;
ycv = chirp(tcv,fo,1,f1,"quadratic",[],"concave");

チャープのスペクトログラムを計算して表示します。

figure
nexttile
pspectrum(ycx,tcx,"spectrogram", ...
    Leakage=0.85,TimeResolution=0.1,OverlapPercent=99)
title("Convex Chirp")

nexttile
pspectrum(ycv,tcv,"spectrogram", ...
    Leakage=0.85,TimeResolution=0.1,OverlapPercent=99)
title("Concave Chirp")

Figure contains 2 axes objects. Axes object 1 with title Convex Chirp, xlabel Time (ms), ylabel Frequency (Hz) contains an object of type image. Axes object 2 with title Concave Chirp, xlabel Time (ms), ylabel Frequency (Hz) contains an object of type image.

別のファンクション ジェネレーターはvco (電圧制御発振器) で、入力ベクトルによって決定された周波数で振動する信号を生成します。入力ベクトルは、三角形、矩形、正弦波などにすることができます。

瞬間的な周波数が三角形となる 10 kHz でサンプリングした 2 秒間の信号を生成します。矩形についても同じく計算します。

fs = 10000;
t = 0:1/fs:2;
x1 = vco(sawtooth(2*pi*t,0.75),[0.1 0.4]*fs,fs);
x2 = vco(square(2*pi*t),[0.1 0.4]*fs,fs);

生成した信号のスペクトログラムをプロットします。

figure
nexttile
pspectrum(x1,t,"spectrogram", ...
    Leakage=0.9,FrequencyResolution=55)
title("VCO Triangle")

nexttile
pspectrum(x2,t,"spectrogram", ...
    Leakage=0.9,FrequencyResolution=55)
title("VCO Rectangle")

Figure contains 2 axes objects. Axes object 1 with title VCO Triangle, xlabel Time (s), ylabel Frequency (kHz) contains an object of type image. Axes object 2 with title VCO Rectangle, xlabel Time (s), ylabel Frequency (kHz) contains an object of type image.

パルス列

パルス列を生成するには、関数pulstranを使用します。

レート 100 GHz、間隔 7.5 ns でサンプリングされた 1 ns の矩形パルスの列を生成します。

fs = 100e9;
D = [2.5 10 17.5]' * 1e-9;
t = 0 : 1/fs : 2500/fs;
w = 1e-9;
yp = pulstran(t,D,@rectpuls,w);

10 kHz で 50% の帯域幅をもつ周期性ガウス パルス信号を生成します。パルス繰り返し周波数は 1 kHz、サンプル レートは 50 kHz、パルス列の長さは 10 ms です。反復振幅は毎回 0.8 ずつ減衰します。関数ハンドルを使用して生成関数を指定します。

T = 0 : 1/50e3 : 10e-3;
D = [0 : 1/1e3 : 10e-3 ; 0.8.^(0:10)]';
Y = pulstran(T,D,@gauspuls,10e3,.5);

figure
nexttile
plot(t*1e9,yp)
axis([0 25 -0.2 1.2])
xlabel("Time (ns)")
ylabel("Amplitude")
title("Rectangular Train")

nexttile
plot(T*1e3,Y)
xlabel("Time (ms)")
ylabel("Amplitude")
title("Gaussian Pulse Train")

Figure contains 2 axes objects. Axes object 1 with title Rectangular Train, xlabel Time (ns), ylabel Amplitude contains an object of type line. Axes object 2 with title Gaussian Pulse Train, xlabel Time (ms), ylabel Amplitude contains an object of type line.

参考

| | | | | | | | |