how can i integrate an array with respect to frequency w (omega)? the command "integral" requires function 'fun' to be declared as function of omega. how can i do this?

5 次查看(过去 30 天)
FB and W are frequency responses of two FIR filters fb and w. This is essentially what I am doing:
numer1=(abs(FBW-W)).^2; fun=@(omega) numer1; numer=integral(fun,0,pi,'ArrayValued',true);

采纳的回答

Star Strider
Star Strider 2016-6-26
What you believe you’re doing is not what you’re actually doing.
I’m just guessing here because I don’t have either ‘FB’ or ‘W’:
FBW = @(omega) ... SOMETHING ...;
W = @(omega) ... SOMETHING ELSE ...;
numer1 = @(omega) (abs(FBW(omega)-W(omega))).^2;
fun=@(omega) numer1(omega);
numer=integral(fun,0,pi,'ArrayValued',true);
Also, squaring abs is redundant (unless the argument is complex), because the square will be positive.
NOTE This is obviously UNTESTED CODE. You may have to experiment with it to get it to work in your application.
  6 个评论
Saiankita Anand
Saiankita Anand 2016-6-30
Thank you, Star Strider. You were right. I went back to the documentation of freqz and realized that the frequency vector it returns is in radians/sample and that the frequencies are b/w 0 and pi. My sampling frequency is 16 kHz here but I reckon there is no need for it in this snippet of code as I want to integrate wrt to omega from 0 to pi. Appreciate your help.
Star Strider
Star Strider 2016-6-30
My pleasure.
The equation you posted specifically states integrating on the interval [0,pi], so your code is correct.

请先登录,再进行评论。

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by