Obtain filter x,y points (Designed with notchfilt)

2 views (last 30 days)
Hello everyone,
I am trying to do some Mean Square Error between a signal that I measured and the "ideal" shape of it, which corresponds to a stopband filter. I am able to design the filter by using notchspec, design and notchfilt. However, I would like to get the data points plotted on the image by fvtool, to perform MSE. I have not been able to find how to do it at all.
I would really appreciate some advice!
The code that I use to generate the filter:
F0 = 105e9; % Notch
Fs = 250e9; % Sampling freq
Q = 10;
BW = 10e9;
orderFilter = 2;
notchspec = fdesign.notch('N,F0,Q',orderFilter,F0,Q,Fs);
notchfilt = design(notchspec,'IIR','SystemObject',true);
fvtool(notchfilt,'Color','white');
%ylim([-30 0])
%xlim([75 110])

Answers (1)

Pratyush Roy
Pratyush Roy on 28 Sep 2021
Hi Jesus,
As per my understanding, you want to get the data ponts of the ideal response plotted on the image generated by fvtool.
This can be done once we get the fvtool handle. You can refer to the code snippet given below for details:
F0 = 105e9; % Notch
Fs = 250e9; % Sampling freq
Q = 10;
BW = 10e9;
orderFilter = 2;
notchspec = fdesign.notch('N,F0,Q',orderFilter,F0,Q,Fs);
notchfilt = design(notchspec,'IIR','SystemObject',true);
h = fvtool(notchfilt,'Color','white');
%% h is the fvtool handle. We will get the axis objects from the fvtool and
% use that to superimpose the ideal response
s = get(h);
hchildren = s.Children;
haxes = hchildren(strcmpi(get(hchildren,'type'),'axes'));
hline = get(haxes,'children');
x = get(hline,'XData');
y = get(hline,'YData');
y1 = randn(1,8192); % Using random noise for example. You can replace that with your own ideal response
% data points here
line(haxes,x,y1)
Hope this helps!

Community Treasure Hunt

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

Start Hunting!