How to specify which version of a function to use?

7 次查看(过去 30 天)
I am trying to run the grpdelay.m function which calculates the group delay in samples of a filter given certain inputs.
There are two similar input methods for the function. It is calling the wrong one for me but I'm not sure how to tell it to call the right one.
Here are the two similar input methods:
## [g, f] = grpdelay(b,a,n,Fs)
## evaluates the group delay at n frequencies between 0 and Fs/2.
##
## [g, f] = grpdelay(b,a,f,Fs)
## evaluates the group delay at frequencies f (in Hz).
I would like the second option. Ie. I want to specify a frequency "f" and calculate the group delay at that frequency. However, it keeps running the first option instead, giving me the group delay at "n" frequencies.
How do I force it to take the third input variable as "f" rather than "n"?
Here is my sample code:
g = 0.903228;
a1 = -1.88142;
a2 = 0.903228;
B1 = -2.08299;
B2 = 1.10714;
b = g * [1, B1, B2];
a = [1,a1,a2];
f = 82.2;
Fs = 44100;
[g, f] = grpdelay(b,a,f,Fs);
[g, f]
Rather than outputing just one group delay at 82.2 Hz, it is outputting 82 different group delays across the frequency spectrum.
What am I doing wrong? Thanks.

采纳的回答

Stephen23
Stephen23 2020-5-14
编辑:Stephen23 2020-5-14
The grpdelay documentation states "Frequencies, specified as a vector. fin must have at least two elements, because otherwise the function interprets it as n".
So the simple solution would be to provide two frequencies and remove the corresponding element from the outputs. You might even find use NaN as the extra input frequencies will work.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Digital Filter Analysis 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by