• We've upgraded our forums. Please post any issues/requests in this thread.

Assistance trying to put textbook equations into MATLAB

Joined
May 27, 2008
Messages
3,577 (1.03/day)
Likes
533
Location
Huddersfield, uk
Processor E8200
Motherboard Asus P5KC
Cooling cooler master hyper tx3, 2x 120mm, 1x 80mm
Memory 4 GB DDR3 OCZ Black Edition
Video Card(s) Gigabyte HD 2600xt silent pipe II
Storage 500GB WD Sata / 60 GB Samsung IDE
Display(s) 20" samusng LCD, gaming at 1680 x 1050
Case some old amd thing
Audio Device(s) onboard
Power Supply 650W
Software Windows 8.1, with 'start is back' obviously
Benchmark Scores It boots whilst im still young so im pleased with that.
#1
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
Joined
Nov 29, 2009
Messages
9,376 (3.19/day)
Likes
2,100
Location
Home
System Name Asus K50-X5DAB \\ Orange!
Processor Athlon QL-65 2.2Ghz \\ 3570K
Motherboard Laptop \\ ASRock z77 Extreme4
Cooling Laptop \\ H100i
Memory 1x1GB + 1X2GB \\ 2x4Gb 1600Mhz CL9 Corsair XMS3
Video Card(s) Mobility Radeon HD4570 512mb \\ Zotac 660Ti OC 2Gb
Storage 250Gb \\ Samsung 840 250Gb + Toshiba DT01ACA300 3Tb
Display(s) 15.6" 1366x768 \\ LG 22EA53VQ
Case Laptop Chassis \\ NZXT Phantom 410 Black/Orange
Power Supply Power Brick \\ Corsair CXM500w
#2
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.
 
Joined
Sep 1, 2010
Messages
5,899 (2.22/day)
Likes
6,563
#3
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
 
Joined
May 27, 2008
Messages
3,577 (1.03/day)
Likes
533
Location
Huddersfield, uk
Processor E8200
Motherboard Asus P5KC
Cooling cooler master hyper tx3, 2x 120mm, 1x 80mm
Memory 4 GB DDR3 OCZ Black Edition
Video Card(s) Gigabyte HD 2600xt silent pipe II
Storage 500GB WD Sata / 60 GB Samsung IDE
Display(s) 20" samusng LCD, gaming at 1680 x 1050
Case some old amd thing
Audio Device(s) onboard
Power Supply 650W
Software Windows 8.1, with 'start is back' obviously
Benchmark Scores It boots whilst im still young so im pleased with that.
#4
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.