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)
0 件のコメント
採用された回答
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")
% Let's plot the magnitude and compare with freqz() plot
figure
plot(w,h)
xlabel("Normalized Freq (rad/sample)")
ylabel("Magnitude (dB)")
参考
カテゴリ
Help Center および File Exchange で Spectral Measurements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!