Figure Output blank but no errors

8 ビュー (過去 30 日間)
S
S 2024 年 2 月 3 日
コメント済み: Aquatris 2024 年 2 月 5 日
I am trying to plot the frequency response of all of the outputs as shown below, for some reason figure 2 is just blank. I have no errors so I am unsure what is wrong. Thanks for your time!
close all
fs = 20e3;
numFilts = 32;
filter_number = 5;
CenterFreqs = logspace(log10(50), log10(8000), numFilts);
t = linspace(0,2*pi,200);
input = sin(t) + 0.25*rand(size(t));
%
figure
hold on
for ii = 1:filter_number
output = gammatone(input, CenterFreqs(ii), fs);
plot(output)
end
Unrecognized function or variable 'gammatone'.
figure
[h{ii},f] = freqz(output(ii),1,4*8192,fs);

回答 (1 件)

Aquatris
Aquatris 2024 年 2 月 3 日
編集済み: Aquatris 2024 年 2 月 3 日
When you call freqz with outputs, it does not draw a plot as written on the description of the function. So you need to do
[h,w] = freqz(b,a,'whole',2001);
plot(w/pi,20*log10(abs(h))) % specific call to plot
as shown in the documentation. If you open the freqz function code and check line 174 (Matlab 2023a) you will also see it only plots if there are no output arguments.
  9 件のコメント
S
S 2024 年 2 月 5 日
So I changes the line for output to this hoping it would fix it. What I want is for each output to be graphed. Since they are in cascade the output of one is the input to the next, so I am trying to plot all the outputs of every filter number. What I have below is not working though
output(ii,:) = gammatone(input, CenterFreqs(ii), fs);
plot(t,output(ii,:), 'LineWidth', 1.25)
Aquatris
Aquatris 2024 年 2 月 5 日
Define not working? What do you expect and what is happenig? What do you have in output variable?
Are you sure your gammatone function works properly?
Be more specific otherwise no one can help you.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by