Main Content

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

FVTool を使用したフィルター解析

この例は、Signal Processing Toolbox™ で利用可能なグラフィカル ユーザー インターフェイスである、フィルターの可視化ツール (FVTool) によって、いくつかのフィルター解析関数を 1 つの Figure ウィンドウで利用する方法を示します。

FVTool は Application Program Interface (API) をもち、これがコマンド ラインからの GUI との対話を可能にしています。これにより、FVTool と他のアプリケーションの統合が可能になります。

FVTool の起動

通過帯域周波数 0.4π ラジアン/サンプル、阻止帯域周波数 0.6π ラジアン/サンプル、通過帯域リップル 1 dB、阻止帯域の減衰量 80 dB をもつローパス フィルターを作成します。ここでは、いくつかの Signal Processing Toolbox フィルター設計ツールを使用してフィルターを設計し、結果を FVTool で解析します。

ローパス等リップル FIR フィルターを設計します。

Df1 = designfilt("lowpassfir",PassbandFrequency=0.4,...
                              StopbandFrequency=0.6,...
                              PassbandRipple=1,...
                              StopbandAttenuation=80,...
                              DesignMethod="equiripple");

ローパス楕円 IIR フィルターを設計します。

Df2 = designfilt("lowpassiir",PassbandFrequency=0.4,...
                              StopbandFrequency=0.6,...
                              PassbandRipple=1,...
                              StopbandAttenuation=80,...
                              DesignMethod="ellip");

フィルター オブジェクトを使用して FVTool を起動し、ハンドルを FVTool に返すことで、同じ FVTool Figure を再使用できます。

hfvt = fvtool(Df1,Df2);

Figure Figure 1: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Normalized Frequency ( times pi blank rad/sample), ylabel Magnitude (dB) contains 2 objects of type line.

フィルターの追加と削除

両方のフィルターが設計仕様を満たしているかが確認できますが、また、チェビシェフ II 型設計がどの程度正しく動作するかも確認します。

フィルターを FVTool に追加するには、関数 addfilter を使用します。

Df3 = designfilt("lowpassiir",PassbandFrequency=0.4,...
                              StopbandFrequency=0.6,...
                              PassbandRipple=1,...
                              StopbandAttenuation=80,...
                              DesignMethod="cheby2");
addfilter(hfvt,Df3);

Figure Figure 1: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Normalized Frequency ( times pi blank rad/sample), ylabel Magnitude (dB) contains 3 objects of type line.

プロット上のどの線がどのフィルターに属しているかを識別できるように、FVTool ハンドルの関数 legend で凡例を追加できます。

legend(hfvt,"Equiripple","Elliptic","Chebyshev Type II");

Figure Figure 1: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Normalized Frequency ( times pi blank rad/sample), ylabel Magnitude (dB) contains 3 objects of type line. These objects represent Equiripple, Elliptic, Chebyshev Type II.

FVTool からフィルターを削除するには、関数 deletefilter を使用して、削除するフィルターのインデックスを渡します。

deletefilter(hfvt,[1 3]);

Figure Figure 1: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Normalized Frequency ( times pi blank rad/sample), ylabel Magnitude (dB) contains an object of type line. This object represents Elliptic.

解析パラメーターの変更

FVTool によって返されるハンドルには、フィルターと現在の解析の両方を操作するためのプロパティが含まれています。使用可能なすべてのプロパティを確認するには、get コマンドを使用します。FVTool 固有の最後の 14 個のプロパティを表示します。

s = get(hfvt);

Figure Figure 1: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Normalized Frequency ( times pi blank rad/sample), ylabel Magnitude (dB) contains an object of type line. This object represents Elliptic.

% Keep the last 14 properties
c = struct2cell(s);
f = fieldnames(s);
s = cell2struct(c(end-14:end),f(end-14:end),1)
s = struct with fields:
       SelectionHighlight: on
                      Tag: 'filtervisualizationtool'
                 UserData: []
                  Visible: on
           FrequencyScale: 'Linear'
                 Analysis: 'magnitude'
      NormalizedFrequency: 'on'
           FrequencyRange: '[0, pi)'
          FrequencyVector: [0 0.0039 0.0078 0.0118 0.0157 0.0196 0.0235 0.0275 0.0314 0.0353 0.0392 0.0431 0.0471 0.0510 0.0549 0.0588 0.0627 0.0667 0.0706 0.0745 0.0784 0.0824 0.0863 0.0902 0.0941 0.0980 0.1020 0.1059 0.1098 0.1137 ... ] (1x256 double)
        OverlayedAnalysis: ''
         MagnitudeDisplay: 'Magnitude (dB)'
            PolyphaseView: 'off'
            ShowReference: 'on'
           NumberofPoints: 8192
    NormalizeMagnitudeto1: 'off'

FVTool の [解析パラメーター] ダイアログで使用可能なパラメーターはすべて、FVTool オブジェクトのプロパティとしても使用可能です。set コマンドを 2 つの入力引数のみで使用すると、すべての可能な値が返されます。

set(hfvt,"MagnitudeDisplay")
ans = 1x4 cell
    {'Magnitude'}    {'Magnitude (dB)'}    {'Magnitude squared'}    {'Zero-phase'}

表示を Magnitude Squared にします。

hfvt.MagnitudeDisplay = "Magnitude Squared";

Figure Figure 1: Magnitude Response (squared) contains an axes object. The axes object with title Magnitude Response (squared), xlabel Normalized Frequency ( times pi blank rad/sample), ylabel Magnitude squared contains an object of type line. This object represents Elliptic.

Analysis プロパティのすべての可能な値を取得します。

set(hfvt,"Analysis")
ans = 1x12 cell
    {'magnitude'}    {'phase'}    {'freq'}    {'grpdelay'}    {'phasedelay'}    {'impulse'}    {'step'}    {'polezero'}    {'coefficients'}    {'info'}    {'magestimate'}    {'noisepower'}

次に、解析を変更してフィルターの群遅延応答を確認します。既定の単位を表示します。

hfvt.Analysis = "grpdelay";

Figure Figure 1: Group delay contains an axes object. The axes object with title Group delay, xlabel Normalized Frequency ( times pi blank rad/sample), ylabel Group delay (in samples) contains an object of type line. This object represents Elliptic.

GroupDelayUnits = hfvt.GroupDelayUnits
GroupDelayUnits = 
'Samples'

2 つの解析結果の重ね描き

ここでは、群遅延と振幅応答が周波数領域でどのように重なるのかを確認します。

FVTool で共通の x 軸 (時間または周波数) を共有する 2 つの解析を重ね描きするには、OverlayedAnalysis プロパティを設定します。

set(hfvt,OverlayedAnalysis="magnitude",Legend="On")

Figure Figure 1: Group delay and Magnitude Response (dB) contains an axes object. The axes object with title Group delay and Magnitude Response (dB), xlabel Normalized Frequency ( times pi blank rad/sample), ylabel Group delay (in samples) contains an object of type line. This object represents Elliptic: Group delay.

重ね描きした解析をオフにするには、OverlayedAnalysis プロパティを '' に設定します。

hfvt.OverlayedAnalysis = '';

Figure Figure 1: Group delay contains an axes object. The axes object with title Group delay, xlabel Normalized Frequency ( times pi blank rad/sample), ylabel Group delay (in samples) contains an object of type line. This object represents Elliptic.

FVTool Figure を閉じるには、FVTool ハンドル上で関数 close を呼び出します。

close(hfvt)

参考

|