Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dsp: p_fir: implementation error #151

Open
lfochamon opened this issue Jun 16, 2015 · 2 comments
Open

dsp: p_fir: implementation error #151

lfochamon opened this issue Jun 16, 2015 · 2 comments

Comments

@lfochamon
Copy link
Contributor

Current p_fir implementation is incorrect. Using the inputs:

float x[10] = {1,2,3,4,5,6,7,8,9,10};
float h[8] = {1,2,3,4,5,6,7,8};
int nx = 10;
int nh = 8;

it outputs:

176.0, 156.0, 144.0, 140.0, 144.0, 156.0, 176.0, 204.0, 464.0, 444.0, 432.0,
428.0, 432.0, 444.0, 464.0, 492.0

while MATLAB gives

filter(1:8, 1,1:10) = 1.0, 4.0, 10.0, 20.0, 35.0, 56.0, 84.0, 120.0, 156.0, 192.0

Moreover, it goes beyond the buffer limit (the output should've been 10 samples).

@ebadi
Copy link
Contributor

ebadi commented Jun 16, 2015

I also use Matlab to check function outputs (#148)
Not an expert in dsp, but are you sure "filter" is the right function? You may be interested to take a look at the following URL : http://se.mathworks.com/help/signal/ug/fir-filter-design.html

@lfochamon
Copy link
Contributor Author

Hey! Well, filter is the function that implements filtering in MATLAB (both FIR and IIR). The link you sent me is for function to design filter coefficients. From what I understood (could be wrong) from the description and the current code in p_fir it should filter samples GIVEN the filter coefficients. Technically, it behaves like conv, except the output is the same length as the input. In other words, whereas conv returns nh+nx-1, filter returns nx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants