MATLAB Answers

FVTool: filter array as parameter

9 views (last 30 days)
I would like to pass a filter vector as a parameter to FVTool to automate different plots of my MATLAB script.
Example: I have this:
plotter = fvtool(getFilter(octaveFilterBank{1}), ...
getFilter(octaveFilterBank{2}), ...
'FrequencyScale', 'log', ...
'Fs', Fs);
I want something like this:
% Init the array:
filter_array = [getFilter(octaveFilterBank{1}), ...
getFilter(octaveFilterBank{2})];
% Plot:
plotter = fvtool(filter_array, ...
'FrequencyScale', 'log', ...
'Fs', Fs);
How can I do this?

  0 Comments

Sign in to comment.

Accepted Answer

Gabriele Bunkheila
Gabriele Bunkheila on 8 Jan 2018
Hi Nycholas,
Please give the following a try and let us know if it works for you:
filter1 = octaveFilter('CenterFrequency',1000);
filter2 = octaveFilter('CenterFrequency',2000);
filterArray = {getFilter(filter1), getFilter(filter2)};
fvtool(filterArray{:})
Thanks,
Gabriele.

  1 Comment

Nycholas Maia
Nycholas Maia on 8 Jan 2018
Thank you Gabriele! You are right! Now it's working!
In my case, my final code is:
% Preallocate the filter bank:
octaveFilterBank = cell(1, 5);
for n = 1:5
% Change the Center Frequency Dinamically:
freq = 1000 * n;
% Get the filter:
filter = getFilter(octaveFilter('CenterFrequency', freq));
% Add to filter array:
octaveFilterBank{n} = filter;
end
% Plot filter array:
fvtool(octaveFilterBank{:})

Sign in to comment.

More Answers (0)