Z domain transfer function filter

15 views (last 30 days)
John Lynn
John Lynn on 15 Jul 2015
Commented: Star Strider on 16 Jul 2015
Hi there,
I'm working on a project for a class that involves making a filter from a Z domain transfer function and I'm having trouble understanding what I've got wrong. The flow of the project requires that I generate a chirp over a certain frequency and apply it to the transfer function as input. Then I need to make a new transfer function that is causal/stable and use it as a filter for a music file. I'm running into an error when running the 'lsim' line (the array goes to NaN at term 2042) which leads to an all NaN array at the 'ifft' line. Anybody have any thoughts on what I'm doing wrong?
  2 Comments
Star Strider
Star Strider on 15 Jul 2015
I don’t understand what you’re doing. Using a control system as a filter is a novel approach, but I don’t understand your filtering the fft of the signal rather than the signal itself, since discrete filters and control systems generally operate in the time domain rather than the frequency domain in practice.
Also, if you want us to be able to run your code and simulate it, post or attach the code rather than a screenshot of it. (If you attach it, use the ‘paperclip’ icon and complete both steps: ‘Choose file’ and ‘Attach file’.)
John Lynn
John Lynn on 15 Jul 2015
Thanks for the reply. Honestly I wondered that myself, it's a project for a discrete signals and systems class and he doesn't want us to use Matlab filter functions for whatever reason. I was told that I needed to take the fft of the signal before running it through the transfer function which doesn't make sense either. Sorry about the screenshot, this was my first question and didn't think too much about it. I'll attach the file.

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 16 Jul 2015
If you have access to Proakis’s Digital Signal Processing, Fourth Edition (ISBN 0-13-187374-1), check pages 480-488. It is probably what you want. It describes essentially the Signal Processing Toolbox fftfilt function.
If you can’t do that because of your imposed constraints, one option would be to take the two-sided fft of your signal, express your transfer function in s-space (instead of z-space), substitute s=j*w (with w=2*pi*f with f in Hz), using linspace to define your transfer function over the length (both sides) of your fft, and then do element-wise multiplication (.*) and division (./).
I didn’t actually try this, but it works in theory.
  2 Comments
John Lynn
John Lynn on 16 Jul 2015
Great, thank you! That's actually the book we're using for the course. I can't use any built-in filter functions so I'll try the s-space solution and see what happens.
Star Strider
Star Strider on 16 Jul 2015
My pleasure!
We discussed that in my DSP courses, but never actually did it.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!