2
votes

I need do the cross correlation between two signals in c++ application. I use some libraries but result are differents of xcorr matlab function. Also I read something about that I can convert matlab code to c or c++ code but I don't know how.

So, how can i do to convert only xcorr to c++ code and use in my program? or Do you know some good implementation of cross correlation in c++?

Thanks

1
There is a application in Matlab that lets you create .c and .cpp with .dll files to add to your C++ project. Google it ;)Ander Biguri
If I were you, I'd take another look at your Matlab and C++ code, and see if you made a real one-to-one translation. There must just be a bug somewhere. Finding a tool and automatically converting your Matlab code to C++ will only make your project more difficult to manage.JorenHeit
you might be interested in this to understand how MATLAB implements xcorr: stackoverflow.com/a/3950552Amro

1 Answers

2
votes

There seem to be two questions in your posting:

  1. Why doesn't my C library function give the same answer as xcorr() in Matlab?
  2. How can I convert the Matlab xcorr() function into C++?

In answer to (2), you can use the Matlab Coder: http://www.mathworks.co.uk/products/matlab-coder to generate C/C++ from Matlab code. The xcorr() function is supported.

I can't really help with (1) without more information. Could you post the source code, or a reference to the library? What do you mean by "results are different"? Do you mean small numerical differences, or completeley different results?