# Filtering Audio Signals in MATLAB

I'm trying to apply a filter to an audio signal in MATLAB and having some trouble processing it.

So far, I have a transfer function that describes a K-weighted filter, and I am able to create a bode plot that looks correct.

Here is the script for that one:

I have another script that reads audio from a .wav file, plays it, and plots the waveform.

That works properly too. Now I want to run that audio file through the K-weighted filter but I'm having trouble with that part.

I am able to use the "designfilt" and "filter" functions to create various filters and process the audio, but I can't get that to work with the transfer function I've created.

My transfer function PF is expressed in the z domain, but it doesn't show up as a proper digital filter in MATLAB.

Is there a way to create a digital filter from my PF transfer function or its coefficients directly?

I've tried using "filtfilt" and "lsim" to process the audio but I haven't had any luck yet.

I've also tried "output=filter(PF,audio)", which returns an error message saying there aren't enough input arguments, and "output=filter(b1,a1,audio)" which returns a matrix that says "NaN" repeatedly.

I'm sure there's something obvious I'm missing or some syntax errors, hopefully somebody here can point me in the right direction.

 dataout = filter(TF,datain);