フィルターのクリア

Obtain filter x,y points (Designed with notchfilt)

2 ビュー (過去 30 日間)
Jesus Sanchez
Jesus Sanchez 2021 年 9 月 21 日
回答済み: Pratyush Roy 2021 年 9 月 28 日
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])

回答 (1 件)

Pratyush Roy
Pratyush Roy 2021 年 9 月 28 日
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!

カテゴリ

Help Center および File ExchangeSingle-Rate Filters についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by