get specific magnitude response value given a specific frequency from a freqz graph

7 ビュー (過去 30 日間)
Hi Team,
I have plotted a Magnitude response vs Normalized frequency graph through freqz. I would like to calculate the corresponding magnitude response values for specific normalized frequencies without having to observe on the graph.
e.g for a normalized frequency value of 0.3pi rad/sample i expect this much DB from the graph. Kindly assist.
See my code snippet so far: Given a H(z):
[b,a] = tfdata(Hz,'v');
figure(2);
freqz(b,a)

採用された回答

Abderrahim. B
Abderrahim. B 2022 年 7 月 14 日
編集済み: Abderrahim. B 2022 年 7 月 14 日
Hi!
Try this:
% Since you did not share Hz, I am loading tfData.mat
load('tfData.mat','sys1');
Hz = sys1 ;
[b, a] = tfdata(Hz) ;
% Convert a and b from cell to mat
a = cell2mat(a) ;
b = cell2mat(b) ;
[h,w] = freqz(b,a) ;
% Convert to db and rad/sample
h = 20*log10(abs(h)) ;
w = w/pi ;
% e.g for a normalized frequency w(200) (normalized freq at index 200),
% the magnitude is:
w_eg = w(200) ;
h_eg = h(w == w_eg) ;
disp("The magnitude at " + w_eg + " rad/sample is " + h_eg + " dB")
The magnitude at 0.38867 rad/sample is -1.8019 dB
% Let's plot the magnitude and compare with freqz() plot
figure
plot(w,h)
xlabel("Normalized Freq (rad/sample)")
ylabel("Magnitude (dB)")

その他の回答 (1 件)

Paul
Paul 2022 年 7 月 14 日
編集済み: Paul 2022 年 7 月 14 日
freqz accepts a third argument that allows the user to specify the desired angular frequencies to evaluate (it must have at least two elements)
h = freqz(b,a,w);
absh = abs(h) % magnitude respose
% or
absh = abs(freqz(b,a,w));

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by