Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Crosscorrel.cpp
- Revision:
- 0:61544337ff5e
diff -r 000000000000 -r 61544337ff5e Crosscorrel.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Crosscorrel.cpp Thu May 03 20:39:50 2018 +0000
@@ -0,0 +1,37 @@
+#include "Crosscorrel.h"
+#include "mbed.h"
+
+Crosscorrel::Crosscorrel()
+{
+ this->tau = 50;
+}
+
+float Crosscorrel::GetMax(SignalBuf &buf, unsigned chA, unsigned chB)
+{
+ float max = 0;
+ for(int j = -tau; j <= tau; j++)
+ {
+ float correl = 0;
+
+ for(unsigned t = 0; t < buf.size(); t++)
+ {
+ correl += buf[t][chA] * GetValue(buf, t+j, chB);
+ }
+ printf("%i\n", int(correl));
+ max = correl > max ? correl : max;
+ }
+ return max;
+}
+
+Crosscorrel::~Crosscorrel()
+{
+
+}
+
+float Crosscorrel::GetValue(SignalBuf &buf, int index, unsigned ch)
+{
+ if(index < 0 || index >= buf.size())
+ return 0;
+
+ return buf[index][ch];
+}
\ No newline at end of file
