Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

correlate function

Hi Gurus, I am using the correlate function to correlate to vectors of type CNiReal64, to test if the returned corrolation vector was right I inputed, to identical vectors. I was expected to have a single value of one returned... Instead I have 3.5*10-63....

I paste my code where array1 is input 1, array2 is input2 and correl is output..

Do you see anything wrong???

double *array1 = new double[nbrSamples];
double *array2 = new double[nbrSamples];
double correl[1];


CNiMath :: Correlate(CNiReal64Vector(nbrSamples,array1),CNiReal64Vector(nbrSamples,array2),
CNiReal64Vector(1,correl));

char swap[10];
sprintf(swap,"%g",correl[0])/*(double)sumcorrel/(double)nbrSegments)*/;
AfxMessageBox(swap);
0 Kudos
Message 1 of 2
(2,911 Views)
Hello

One thing that sticks out is the way you are returning Rxy from the correlate function. The way you have it right now,the CniReal64Vector is making a copy of correl, and the actual value of Rxy is returned in a variable that exist temporarily on the stack. You should have some like

CNiReal64Vector Rxy(1,0.0);
CNiMath::Correlate(CNiReal64Vector (4,0.0),CNiReal64Vector (4,0.0),Rxy);

Now Rxy is be the vector containg the Correlation data of the input arrays
And I think the documentation is incorrect. The size of the return array is actaully m+n-1. I will file a CAR about this though.

I hope this helps

Let me know if I missed anything

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 2
(2,911 Views)