フィルターのクリア

Extract magnitude response in dB using fvtool(_) or freqz(_)

15 ビュー (過去 30 日間)
Shannon Cherry
Shannon Cherry 2021 年 8 月 4 日
コメント済み: Shannon Cherry 2021 年 8 月 4 日
Hi, I have some filter coefficients 'h' and I am plotting the frequency response using fvtool(h) or freq(z).
Now, I would like to know the magnitude response (Y-axis) values of any given Normalized frequency (X-axis) shown in the figure (attached).
I have to manually place a cursor on Normalized frequency (X-axis) and drag it to a point to know its corresponding Y-axis value as shown below.
Example: Y-axis value (Magnitude) = 0.3523 for a given X-axis value (Normalized frequency) 0.2427.
This is quite uncomfortable when I want to know the Y-axis values for 100s of X-axis values. Is there any alternative way or MATLAB command to get the Y-axis values for any given X axis value?

採用された回答

Pere Garau Burguera
Pere Garau Burguera 2021 年 8 月 4 日
You can still use freqz, and in h you get the frequency response.
[h,w] = freqz(z);
This returns an array of 8192 elements, you can change this number with
[h,w] = freqz(z,n);
Then
freqz(z)
without assigning it to a variable is what you have been doing, and it automatically plot the response for you (which actually uses fvtool), as indicated in freqz.
Where n is the number of samples of the frequency response. Check freqz for more info.
Since h is complex you can then get the magnitude with
h_mag = abs(h);
And the phase with
h_ph = angle(h);
  3 件のコメント
Pere Garau Burguera
Pere Garau Burguera 2021 年 8 月 4 日
To convert from linear to logarithmic, you can use
h_db = 10*log10(h_mag);
Shannon Cherry
Shannon Cherry 2021 年 8 月 4 日
Thanks. This works.

サインインしてコメントする。

その他の回答 (1 件)

Chunru
Chunru 2021 年 8 月 4 日
fvtool visualizes filter frequency response and it has no return value. freqz returns the frequency response and has the syntax such as "[h,f] = freqz(___,n,fs)". You should use freqz to get the response h vs f.

カテゴリ

Help Center および File ExchangeFilter Design についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by