1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Assistance trying to put textbook equations into MATLAB

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

  1. ste2425

    ste2425

    Joined:
    May 27, 2008
    Messages:
    3,357 (1.56/day)
    Thanks Received:
    356
    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.

    [​IMG]

    [​IMG]
  2. Fourstaff

    Fourstaff Moderator Staff Member

    Joined:
    Nov 29, 2009
    Messages:
    9,099 (5.68/day)
    Thanks Received:
    1,943
    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

    Drone

    Joined:
    Sep 1, 2010
    Messages:
    2,345 (1.77/day)
    Thanks Received:
    1,063
    Location:
    Hell
    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

    ste2425

    Joined:
    May 27, 2008
    Messages:
    3,357 (1.56/day)
    Thanks Received:
    356
    Location:
    Huddersfield, uk
    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.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page