Results 1 to 5 of 5
  1. #1
    paulachrist is offline Member
    Join Date
    Jul 2008
    Posts
    6
    Rep Power
    0

    Default Any ideas to create a filter program?

    Hello, newbie here.

    I need to build a filter program which takes in some sample numbers as inputs and and get the outputs, any ideas?

    Java Code:
    My 300 sample numbers as input x(n) are below,
    0.757558
    0.172461
    0.168066
    0.170996
    0.160010
    0.147559
    0.148291
    0.138770
    0.148291
    0.124121
    0.140234
    0.129248
    0.124854
    0.118994
    0.128516
    0.120459
    0.110938
    0.112402
    0.104346
    0.099219
    0.098486
    0.094092
    0.099951
    0.100684
    0.097754
    0.091162
    0.098486
    0.104346
    0.102148
    0.091895
    0.088232
    0.089697
    0.104346
    0.079443
    0.086768
    0.086035
    0.086035
    0.093359
    0.086035
    0.096289
    0.094824
    0.094092
    0.092627
    0.097754
    0.097021
    0.100684
    0.100684
    0.104346
    0.099219
    0.096289
    0.094824
    0.102881
    0.094824
    0.088232
    0.087500
    0.090430
    0.088965
    0.091162
    0.103613
    0.106543
    0.099951
    0.110205
    0.119727
    0.125586
    0.142432
    0.150488
    0.146094
    0.159277
    0.196631
    0.192236
    0.177588
    0.190039
    0.169531
    0.140234
    0.105811
    0.091162
    0.092627
    0.080176
    0.076514
    0.079443
    0.082373
    0.084570
    0.083838
    0.090430
    0.156348
    0.335059
    0.628027
    1.057227
    1.172217
    0.979590
    0.594336
    0.459570
    0.264746
    -0.013574
    -0.031885
    0.062598
    0.145361
    0.138770
    0.121191
    0.112402
    0.123389
    0.107275
    0.105078
    0.108008
    0.113867
    0.112402
    0.113135
    0.122656
    0.125586
    0.135107
    0.130713
    0.132178
    0.125586
    0.132178
    0.151221
    0.158545
    0.176123
    0.183447
    0.190039
    0.195898
    0.222266
    0.230322
    0.242041
    0.258887
    0.279395
    0.294043
    0.308691
    0.319678
    0.349707
    0.378271
    0.397314
    0.417822
    0.441992
    0.472754
    0.495459
    0.522559
    0.546729
    0.575293
    0.589209
    0.608984
    0.636084
    0.640479
    0.633887
    0.633154
    0.628760
    0.628027
    0.611914
    0.594336
    0.569434
    0.553320
    0.517432
    0.494727
    0.441260
    0.407568
    0.360693
    0.311621
    0.266211
    0.227393
    0.200293
    0.171729
    0.149756
    0.147559
    0.137305
    0.122656
    0.126318
    0.125586
    0.127783
    0.133643
    0.129980
    0.128516
    0.145361
    0.151221
    0.151953
    0.154883
    0.153418
    0.148291
    0.161475
    0.162939
    0.157080
    0.149023
    0.150488
    0.148291
    0.134375
    0.132910
    0.125586
    0.121191
    0.128516
    0.121191
    0.114600
    0.099951
    0.109473
    0.110205
    0.102881
    0.088965
    0.081641
    0.089697
    0.081641
    0.075781
    0.077246
    0.080176
    0.079443
    0.080908
    0.081641
    0.084570
    0.081641
    0.081641
    0.096289
    0.089697
    0.075781
    0.075049
    0.078711
    0.077246
    0.079443
    0.081641
    0.072852
    0.071387
    0.072852
    0.077979
    0.077246
    0.087500
    0.095557
    0.091895
    0.084570
    0.076514
    0.080908
    0.083838
    0.080176
    0.092627
    0.084570
    0.072852
    0.087500
    0.092627
    0.099219
    0.097754
    0.101416
    0.080176
    0.102148
    0.109473
    0.121191
    0.121191
    0.147559
    0.153418
    0.163672
    0.192969
    0.204688
    0.184180
    0.181250
    0.174658
    0.143896
    0.121191
    0.093359
    0.086768
    0.091895
    0.093359
    0.090430
    0.096289
    0.091895
    0.088232
    0.094092
    0.130713
    0.296240
    0.475684
    0.825049
    1.126074
    1.068945
    0.719580
    0.472754
    0.327002
    0.064062
    -0.036279
    0.013525
    0.092627
    0.153418
    0.146826
    0.135840
    0.133643
    0.138770
    0.128516
    0.121924
    0.123389
    0.143164
    0.158545
    0.140234
    0.138770
    0.143164
    0.146826
    0.156348
    0.166602
    0.176855
    0.188574
    0.190771
    0.198828
    0.217139
    0.222266
    0.226660
    0.238379
    0.244971
    0.275732
    0.285986
    0.288184
    After passing through this filter equation:
    y(n)= y(n-2) + x(n) - 2x(n-6)
    It will calculate the output y(n).

    Cheers

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Are those values in a file? If so you have to read a line by line and pass it through the equation and calculate the output.

    If those values are in a collection, such as array list, etc.. it's much easy to do this. Reading a collection is much easy that reading a file.

    So it's better to provide more details about your question.

  3. #3
    paulachrist is offline Member
    Join Date
    Jul 2008
    Posts
    6
    Rep Power
    0

    Default

    Hello Eranga, my idea sounds like these,

    Filter Equation,
    y(n)= y(n-2) + x(n) - 2x(n-6)

    Input samples->Filter Equation Program->Output samples

    I will let n start from zero,
    y(n) = y(n-2) + x(n) - 2x(n-6)

    y(n) is current output value
    y(n-2) is previous output value
    x(n) is current input value
    2x(n-6) is 2 times of previous input value

    In other words (more details),
    y(0) = y(-2) + x(0) - 2x(-6)
    y(1) = y(-1) + x(1) - 2x(-5)
    y(2) = y(0) + x(2) - 2x(-4)
    y(3) = y(1) + x(3) - 2x(-3)
    y(4) = y(2) + x(4) - 2x(-2)
    y(5) = y(3) + x(5) - 2x(-1)
    y(6) = y(4) + x(6) - 2x(0)
    y(7) = y(5) + x(7) - 2x(1)
    .....
    .....
    .....

    My 300 sample numbers as input x(n) are below,
    0.757558---->n=0
    0.172461---->n=1
    0.168066---->n=2
    0.170996---->n=3
    0.160010---->n=4
    0.147559---->n=5
    0.148291---->n=6
    0.138770---->n=7
    0.148291---->n=8
    0.124121---->n=9
    0.140234---->n=10
    0.129248---->n=11
    ...
    ...
    ...
    ...
    ...



    Emm, just assume the sample values are in a text file because the sample are continuous inputs saved.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,563
    Rep Power
    25

    Default

    Is this a java programming problem? Or an algorithm problem?
    To help you get a java program working, we need to see the program and the full text of any error messages you get. If the output is not what you want, post some of it with an explanation of what is wrong with it and how you want to change it.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Java Performance Ideas
    By developer321 in forum Advanced Java
    Replies: 4
    Last Post: 06-28-2008, 04:16 PM
  2. Merging Ideas
    By CompleteBeginner in forum New To Java
    Replies: 1
    Last Post: 05-19-2008, 02:15 PM
  3. web content filter or internet filter
    By sundarjothi in forum Advanced Java
    Replies: 3
    Last Post: 05-15-2008, 11:36 AM
  4. Need a filter
    By revathi17 in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 07:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •