Re: Any help about FIR filter algorithm
- From: "Rune Allnor" <allnor@xxxxxxxxxxxx>
- Date: 15 Aug 2005 08:57:48 -0700
mariya skrev:
> Hello
>
> Can anyone tell me how i can get an output array from the following piece
> of code.
You are using C or C++? The curly braces indicate you use one of them,
the lack of data formats indicates you don't.
> nm1=N-1;
> yn=0;
Please proviode memory allocations for your buffers.
It will be easier to criticise your code if you allocate
memory, it shows a bit more clearly how you think.
> for(k=0; k<nm1; ++){ /* shift data to make room for new sample */
> x[nm1-k]=x[nm1-k-1];
> x[0]=xn;
> }
You don't have to do it like this, you could use one large buffer
and pointers. But then, you seem to have problems with memory
handling, so leave this as is for now.
> for(k=0; k<N; ++k){
> yn=yn+h[k]*x[k]; /* filter data and compute output sample */
> }
Here you compute one sample that was initialized above.
It is not clear where in memory the accummulated sum will be
stored.
> return(yn); /* filter output sample */
>
> I do understand the basic formula about the FIR filters but as i am trying
> to implement it , i am a bit lost about how to store my outputs in array.
The key here seems to be how to allocate memory for the buffers
and arrays. You need to decide on data types first (float or int
in C/C++), and you need to learn how to allocate memory ("malloc"
in C, "new" in C++).
Once you know how to do that, you are well on your way to get your
function working.
> Any net pages about this algo will be helpfull too!
I think you are close enough, the problem is not the FIR filter
as such, but how to make C/C++ (if you use one of these?) do what
you need it to do. Once the data buffers are sorted out, most of
the work is done.
Rune
.
- Follow-Ups:
- Re: Any help about FIR filter algorithm
- From: mariya
- Re: Any help about FIR filter algorithm
- References:
- Any help about FIR filter algorithm
- From: mariya
- Any help about FIR filter algorithm
- Prev by Date: Wavelet filters
- Next by Date: Re: Silly SNR question
- Previous by thread: Any help about FIR filter algorithm
- Next by thread: Re: Any help about FIR filter algorithm
- Index(es):
Relevant Pages
|
Loading