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);

{"String":"Figure Figure 1: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB) contains 2 objects of type line.","Tex":"Magnitude Response (dB)","LaTex":[]}

フィルターの追加と削除

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

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

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

{"String":"Figure Figure 1: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB) contains 3 objects of type line.","Tex":"Magnitude Response (dB)","LaTex":[]}

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

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

{"String":"Figure Figure 1: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB) contains 3 objects of type line. These objects represent Equiripple, Elliptic, Chebyshev Type II.","Tex":"Magnitude Response (dB)","LaTex":[]}

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

deletefilter(hfvt,[1 3]);

{"String":"Figure Figure 1: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB) contains an object of type line. This object represents Elliptic.","Tex":"Magnitude Response (dB)","LaTex":[]}

解析パラメーターの変更

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

s = get(hfvt);

{"String":"Figure Figure 1: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB) contains an object of type line. This object represents Elliptic.","Tex":"Magnitude Response (dB)","LaTex":[]}

% 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
           FrequencyRange: '[0, pi)'
           FrequencyScale: 'Linear'
            PolyphaseView: 'off'
                 Analysis: 'magnitude'
            ShowReference: 'on'
        OverlayedAnalysis: ''
         MagnitudeDisplay: 'Magnitude (dB)'
          FrequencyVector: [0 0.0039 0.0078 0.0118 0.0157 0.0196 0.0235 ... ]
           NumberofPoints: 8192
    NormalizeMagnitudeto1: 'off'
      NormalizedFrequency: 'on'

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

set(hfvt,"MagnitudeDisplay")
ans = 1x4 cell
  Columns 1 through 3

    {'Magnitude'}    {'Magnitude (dB)'}    {'Magnitude squared'}

  Column 4

    {'Zero-phase'}

表示を Magnitude Squared にします。

hfvt.MagnitudeDisplay = "Magnitude Squared";

{"String":"Figure Figure 1: Magnitude Response (squared) contains an axes object. The axes object with title Magnitude Response (squared) contains an object of type line. This object represents Elliptic.","Tex":"Magnitude Response (squared)","LaTex":[]}

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

set(hfvt,"Analysis")
ans = 1x12 cell
  Columns 1 through 5

    {'magnitude'}    {'phase'}    {'freq'}    {'grpdelay'}    {'phasedelay'}

  Columns 6 through 10

    {'impulse'}    {'step'}    {'polezero'}    {'coefficients'}    {'info'}

  Columns 11 through 12

    {'magestimate'}    {'noisepower'}

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

hfvt.Analysis = "grpdelay";

{"String":"Figure Figure 1: Group delay contains an axes object. The axes object with title Group delay contains an object of type line. This object represents Elliptic.","Tex":"Group delay","LaTex":[]}

GroupDelayUnits = hfvt.GroupDelayUnits
GroupDelayUnits = 
'Samples'

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

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

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

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

{"String":"Figure Figure 1: Group delay and Magnitude Response (dB) contains an axes object. The axes object with title Group delay and Magnitude Response (dB) contains an object of type line. This object represents Elliptic: Group delay.","Tex":"Group delay and Magnitude Response (dB)","LaTex":[]}

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

hfvt.OverlayedAnalysis = '';

{"String":"Figure Figure 1: Group delay contains an axes object. The axes object with title Group delay contains an object of type line. This object represents Elliptic.","Tex":"Group delay","LaTex":[]}

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

close(hfvt)

参考

|