# Assistance trying to put textbook equations into MATLAB

#### ste2425

hi guys

Im on a music tec course at uni and im playing with some DSP.

Ive been able to successfuly create some simple code for low and high pass filters where you just input a center frequency but now im trying to further that by adding a q variable also.

The equations for the coefficents are highlighted in red.

Ino the rest of the code works as it should because when i just change the coeficents values depending on the filter it works. But when i change them to these it plays no sound and the variable y which is my output doesnt contain any samples.

In a nut shell the equations in the text book what am i doing wrong to translate them into my code?

thanks guys hope im making sense

On a side note before you think it im not asking you to do any work for me, this is further reading.

#### Fourstaff

##### Moderator
Staff member
b0=k/(k^2*Q+K+Q) or b0=k/(k^2*(Q+K+Q)) not quite sure what you want.
similar for the rest, you need to add a bracket to group the denominators together otherwise you will end up doing the wrong calculation.

Dont ask me about making time pass stuff, I am struggling with the Fourier Transforms of the time series for now.

#### Drone

It seems that your brackets are all wrong.

It should be something like this:

b0=K/(K*K*Q+K+Q);
b1=0;
b2=-K/(K*K*Q+K+Q);
a1=(2*Q*K*K-2*Q)/(K*K*Q+K+Q);
a2=(K*K*Q-K+Q)/(K*K*Q+K+Q);

However I dunno the purpose of these formulas .. so

#### ste2425

Thank you very much.

Basicly i failed high school maths. So the basic maths that every one expects you to know some of it i struggle with. Like in the equations from the text book, where to put the brackets, or which variables you times by each other. So what i was after was how to write out the equations in the text book.

Which you both showed and now my band-pass filter works. I can sweep through center frequencies and controll the bandwidth basicly a notch filter.

The purpose of the forumlas are that they calculate coeficents to put into a transfer function (or the nice easy filter function in matlab) so that you can create various forms of filters and controll their parameters.