-1
$\begingroup$

What exactly is stored in "output" variable in the FIR Filter code below?

      float filter (float value){
          for (int i = ntaps-1; i>0; i--){
              buffer[i] = buffer[i-1];
          }
          buffer[0] = value;
          for (int i = 0; i<ntaps; i++){
              output += buffer[i]*h[i];
           }
           return ouput;
        }
$\endgroup$

marked as duplicate by Marcus Müller, lennon310, MBaz, Stanley Pawlukiewicz, Peter K. Nov 13 at 19:48

This question was marked as an exact duplicate of an existing question.

  • 1
    $\begingroup$ That's a verbatim duplicate to a question you asked 5 days ago, just about output instead of buffer; already has an answer. You really just need to learn C; if you can't say what output is after having gotten the answer about buffer, then I'm sorry, you really just need to read a C introduction. $\endgroup$ – Marcus Müller Nov 11 at 19:45
0
$\begingroup$

The output variable holds the current output value given the current input value value. It is just the weighted sum of the current and ntaps-1 past input values. Note that this is not the most optimized version of an FIR filter routine.

$\endgroup$
  • $\begingroup$ What exactly will the "output" variable be storing when the "filter" routine is run consecutively with different values of the "value" variable. $\endgroup$ – B. Han Nov 11 at 19:45
  • $\begingroup$ @B.Han: Each time you call it, it holds the new output value corresponding to the new and past input values. $\endgroup$ – Matt L. Nov 11 at 19:55
  • $\begingroup$ How are the new values of the "output" variable related to the old values of the "output" variable? $\endgroup$ – B. Han Nov 11 at 20:20
  • $\begingroup$ @B.Han: They aren't related to the old output values. It's not a recursive filter. $\endgroup$ – Matt L. Nov 11 at 21:29
  • $\begingroup$ When I run the function "filter" the I first time I get a value say "output1". When I run the function "filter" again I get another value say "output2". Please clarify how "output1" and "output2" are related... $\endgroup$ – B. Han Nov 12 at 13:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.