# Assistance trying to put textbook equations into MATLAB

Discussion in 'Programming & Webmastering' started by ste2425, Nov 9, 2012.

1. ### ste2425

Joined:
May 27, 2008
Messages:
3,548 (1.26/day)
485
Location:
Huddersfield, uk
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.

2. ### FourstaffModeratorStaff Member

Joined:
Nov 29, 2009
Messages:
9,304 (4.11/day)
2,051
Location:
Home
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.

3. ### Drone

Joined:
Sep 1, 2010
Messages:
3,846 (1.93/day)
2,977
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

4. ### ste2425

Joined:
May 27, 2008
Messages:
3,548 (1.26/day)