matlab built in functions code
Num and den are the coeficients for the polynomials defining A and B in
H(Z) = B(Z)/A(Z)
When the coeficients of A are zero, except the first one, you made a FIR filter, and just divide all coeficient from B with a0. This is the impulse respone of the filter, and is finite (Finite Impluse Response filter). You can use these coeficients to do a convolution with your input signal.
When there are other coeficients than the first one of A are nonzero, you made an IIR filter (Infinite Impulse response filter). You can find the impulse respone by dividing the polynomials A and B, and you will see it never ends (but the results become smalleer and smaller, I hope). Because the impulse response never ends, it's inpractical to do with convolution.
If you look at how a digital filter works, it will be not to difficult to apply the filter to any input signal.