get specific magnitude response value given a specific frequency from a freqz graph
9 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Abderrahim. B
on 14 Jul 2022
Edited: Abderrahim. B
on 14 Jul 2022
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)")
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!