Thread Subject: infreqz

Subject: infreqz

From: Brett

Date: 9 Feb, 2010 02:33:03

Message: 1 of 9

Hello all!

So, I've been scouring the forum for a while now and I'm having trouble finding successful implementations of the invfreqz function. But moreover, I'm not entirely sure this is the easiest way to even obtain the results I'm looking for, so I suppose I should start from the beginning...

I'm trying to implement a function that will take a source signal, extract its spectral weighting (which I'm doing via spectrogram) and then create a filter with an identical frequency response to the source file. From there, it will be applied to a noise signal to generate a spectra approximation of the original source signal. After reading through the documentation, invfreqz seemed to be my magical cure, but I can't get it to work properly!!! I either end up with a very strange time-domain response or end up getting a frequency response match that is not even close to that of the spectral data I feed the function. Since then, I've resorted to an adaptive filter setup that is fairly inefficient and doesn't match my source particularly well, either...

Anyways, any help that you fine ladies and gents could offer would be much appreciated!

Thanks,
Brett

Subject: infreqz

From: Wayne King

Date: 9 Feb, 2010 12:47:04

Message: 2 of 9

"Brett " <brett.leonard@mcgill.ca> wrote in message <hkqhgv$f5a$1@fred.mathworks.com>...
> Hello all!
>
> So, I've been scouring the forum for a while now and I'm having trouble finding successful implementations of the invfreqz function. But moreover, I'm not entirely sure this is the easiest way to even obtain the results I'm looking for, so I suppose I should start from the beginning...
>
> I'm trying to implement a function that will take a source signal, extract its spectral weighting (which I'm doing via spectrogram) and then create a filter with an identical frequency response to the source file. From there, it will be applied to a noise signal to generate a spectra approximation of the original source signal. After reading through the documentation, invfreqz seemed to be my magical cure, but I can't get it to work properly!!! I either end up with a very strange time-domain response or end up getting a frequency response match that is not even close to that of the spectral data I feed the function. Since then, I've resorted to an adaptive filter setup that is fairly inefficient and doesn't match my source particularly well, either...
>
> Anyways, any help that you fine ladies and gents could offer would be much appreciated!
>
> Thanks,
> Brett

Hi Brett, just a couple questions to clarify. You are inputting the complex-valued frequency response into invfreqz() correct? And you say that you are using spectrogram, are obtaining an impulse response for each column of your spectrogram output, in other words, a filter for each segment in the STFT?

Wayne

Subject: infreqz

From: Brett

Date: 9 Feb, 2010 13:06:04

Message: 3 of 9

> Hi Brett, just a couple questions to clarify. You are inputting the complex-valued frequency response into invfreqz() correct? And you say that you are using spectrogram, are obtaining an impulse response for each column of your spectrogram output, in other words, a filter for each segment in the STFT?
>
> Wayne

Wayne-

Thanks for the response! I am indeed inputing the complex frequency response (in rad/sample) into invfreqz, as obtained by by spectrogram. As for the filtering, I was trying to generate a single filter, not one for each bin; could that be my problem?

Thanks!

Subject: infreqz

From: Wayne King

Date: 9 Feb, 2010 13:30:21

Message: 4 of 9

"Brett " <brett.leonard@mcgill.ca> wrote in message <hkrmjs$nlu$1@fred.mathworks.com>...
> > Hi Brett, just a couple questions to clarify. You are inputting the complex-valued frequency response into invfreqz() correct? And you say that you are using spectrogram, are obtaining an impulse response for each column of your spectrogram output, in other words, a filter for each segment in the STFT?
> >
> > Wayne
>
> Wayne-
>
> Thanks for the response! I am indeed inputing the complex frequency response (in rad/sample) into invfreqz, as obtained by by spectrogram. As for the filtering, I was trying to generate a single filter, not one for each bin; could that be my problem?
>
> Thanks!

Yes, if you have a nonstationary signal that would require some kind of analysis like the STFT, I don't see how you can generate one filter for that process. invfreqz() is returning a filter with a rational Z-transform indicative of a linear time-invariant system.

Wayne

Subject: infreqz

From: Brett

Date: 10 Feb, 2010 00:56:05

Message: 5 of 9

> Yes, if you have a nonstationary signal that would require some kind of analysis like the STFT, I don't see how you can generate one filter for that process. invfreqz() is returning a filter with a rational Z-transform indicative of a linear time-invariant system.
>
> Wayne

OK, that makes total sense. I was, in my haste, neglecting spectrogram's default 8 time segments. Now I've re-worked my code with a simple fft for a single block of time, generating a filter for that time period. And eureka, it seems to work quite nicely!

Looking at the frequency response of the filter created, it's bang on! I'm still having an issue, though. I apply the filter with the coefficients from invfreqz (which I viewed the output of using freqz, with the above stated success) to a vector of white noise. I expect to see the same spectral response out as the filter, with the length of the input vector size. What I get, instead, is a string of zeros followed by a sharp cutoff about a third of the way through the vector. I can't even describe what I'm seeing, really; rather than filtering the signal (in the frequency domain) it just seems to have multiplied by zero and truncated it.

I'm starting to wonder of I'm barking up the wrong tree with invfreqz; all I'm trying to do is impose the frequency response of an input signal (an impulse response, in fact) onto a noise signal with a flat spectrum. And here I was thinking this was going to be easy...

Subject: infreqz

From: Wayne King

Date: 10 Feb, 2010 03:54:03

Message: 6 of 9

"Brett " <brett.leonard@mcgill.ca> wrote in message <hkt075$476$1@fred.mathworks.com>...
> > Yes, if you have a nonstationary signal that would require some kind of analysis like the STFT, I don't see how you can generate one filter for that process. invfreqz() is returning a filter with a rational Z-transform indicative of a linear time-invariant system.
> >
> > Wayne
>
> OK, that makes total sense. I was, in my haste, neglecting spectrogram's default 8 time segments. Now I've re-worked my code with a simple fft for a single block of time, generating a filter for that time period. And eureka, it seems to work quite nicely!
>
> Looking at the frequency response of the filter created, it's bang on! I'm still having an issue, though. I apply the filter with the coefficients from invfreqz (which I viewed the output of using freqz, with the above stated success) to a vector of white noise. I expect to see the same spectral response out as the filter, with the length of the input vector size. What I get, instead, is a string of zeros followed by a sharp cutoff about a third of the way through the vector. I can't even describe what I'm seeing, really; rather than filtering the signal (in the frequency domain) it just seems to have multiplied by zero and truncated it.
>
> I'm starting to wonder of I'm barking up the wrong tree with invfreqz; all I'm trying to do is impose the frequency response of an input signal (an impulse response, in fact) onto a noise signal with a flat spectrum. And here I was thinking this was going to be easy...

What order filter did you specify in invfreqz(). Can you provide your numerator and denominator coefficients (your B and A vectors)? When you say that you applied the filter, how exactly did you do that? Can you show some Matlab code?

Wayne

Subject: infreqz

From: Rajiv Singh

Date: 10 Feb, 2010 19:03:59

Message: 7 of 9

Hi Brett,
It may not have understood your task correctly, but on quick read this looks
like an exercise in time series modeling - you have a signal whose frequency
spectrum needs to be represented by the frequency response of a lienear time
invariant filter. If so, you could try parameteric modeling tools in System
Identification Toolbox, specifically, AR, ARX and ARMAX. The output would be
a parametric model between the signal and a hypothetical white noise source.
You can then run commands like BODE to compute its "frequency response".
Time domain simulations can be peformed using SIM, or you can extract the
model coefficients and create your own ARMA filter representation of the
process.

HTH,
Rajiv


"Brett " <brett.leonard@mcgill.ca> wrote in message
news:hkqhgv$f5a$1@fred.mathworks.com...
> Hello all!
>
> So, I've been scouring the forum for a while now and I'm having trouble
> finding successful implementations of the invfreqz function. But
> moreover, I'm not entirely sure this is the easiest way to even obtain the
> results I'm looking for, so I suppose I should start from the beginning...
>
> I'm trying to implement a function that will take a source signal, extract
> its spectral weighting (which I'm doing via spectrogram) and then create a
> filter with an identical frequency response to the source file. From
> there, it will be applied to a noise signal to generate a spectra
> approximation of the original source signal. After reading through the
> documentation, invfreqz seemed to be my magical cure, but I can't get it
> to work properly!!! I either end up with a very strange time-domain
> response or end up getting a frequency response match that is not even
> close to that of the spectral data I feed the function. Since then, I've
> resorted to an adaptive filter setup that is fairly inefficient and
> doesn't match my source particularly well, either...
>
> Anyways, any help that you fine ladies and gents could offer would be much
> appreciated!
>
> Thanks,
> Brett

Subject: infreqz

From: Brett

Date: 11 Feb, 2010 13:59:07

Message: 8 of 9

> What order filter did you specify in invfreqz(). Can you provide your numerator and denominator coefficients (your B and A vectors)? When you say that you applied the filter, how exactly did you do that? Can you show some Matlab code?
>
> Wayne

Ha, actually, after hours of looking for subtle things, changing coefficients, etc., it ended up being a missed operation in my output scaling... NOW we've got the whole thing working.

Thank you so much for you help! Finally I've got a working prototype for tweaking. Couldn't have done it without you!

Thanks,
Brett

Subject: infreqz

From: Brett

Date: 11 Feb, 2010 14:03:04

Message: 9 of 9

> Hi Brett,
> It may not have understood your task correctly, but on quick read this looks
> like an exercise in time series modeling - you have a signal whose frequency
> spectrum needs to be represented by the frequency response of a lienear time
> invariant filter. If so, you could try parameteric modeling tools in System
> Identification Toolbox, specifically, AR, ARX and ARMAX. The output would be
> a parametric model between the signal and a hypothetical white noise source.
> You can then run commands like BODE to compute its "frequency response".
> Time domain simulations can be peformed using SIM, or you can extract the
> model coefficients and create your own ARMA filter representation of the
> process.
>
> HTH,
> Rajiv

Rajiv-


Thanks for the tips. I haven't touched the System ID Toolbox as of yet (I just got my full

liscence a few weeks ago). I'll check out the modeling tools, though, as they might be a

good alternative method for my processing, as we're looking at any and all options at this

point. The big problem has been trying work with frequency filtering without getting too

many temporal artifacts, as they become quite apparent in high-resolution audio

playback...


Thanks for the tips. I'll check them out and see if they work for my application!

Thanks,
Brett

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
invfreqz Brett 8 Feb, 2010 21:34:09
filter from fre... Brett 8 Feb, 2010 21:34:09
rssFeed for this Thread

Contact us at files@mathworks.com