Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Correlation

Subject: Correlation

From: Hamdullah YOKUS

Date: 28 Jun, 2012 21:31:14

Message: 1 of 6

Hey guys,
My question is about correlation.I have an original signal and a sample signal.I want to correlate the sample signal that is part of the original signal to original one. I wrote that code
signal=walk2(1:745,6);
sample=walk2(1:45,6);
corr=xcorr(signal,sample);
plot(corr);
Since the xcorr gives me the correlation of the two data,I expected corr values will be between -1 and 1.However, they are like between 10^7 to 8*10^7.
Any one knows what the reason of this is.
Thanks.

Subject: Correlation

From: Matt J

Date: 28 Jun, 2012 22:36:20

Message: 2 of 6

"Hamdullah YOKUS" <hamdullahyokus@gmail.com> wrote in message <jsiif2$7hv$1@newscl01ah.mathworks.com>...
> Hey guys,
> My question is about correlation.I have an original signal and a sample signal.I want to correlate the sample signal that is part of the original signal to original one. I wrote that code
> signal=walk2(1:745,6);
> sample=walk2(1:45,6);
> corr=xcorr(signal,sample);
> plot(corr);
> Since the xcorr gives me the correlation of the two data,I expected corr values will be between -1 and 1.However, they are like between 10^7 to 8*10^7.
> Any one knows what the reason of this is.
=============

There is a difference between "correlation" and "correlation coefficient"

http://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient#For_a_sample

Did you normalize your data to have zero mean and unit variance?

Subject: Correlation

From: Hamdullah YOKUS

Date: 29 Jun, 2012 00:45:23

Message: 3 of 6

I normalize my data that have zero mean and unit variance
sgn=(sgn-mean(sgn(:)))/std(sgn(:));
I did for both original signal and sample one;
still gives me the value between -50 to 50;

 
> There is a difference between "correlation" and "correlation coefficient"
>
> http://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient#For_a_sample
>
> Did you normalize your data to have zero mean and unit variance?

Subject: Correlation

From: Matt J

Date: 29 Jun, 2012 01:52:24

Message: 4 of 6

"Hamdullah YOKUS" <hamdullahyokus@gmail.com> wrote in message <jsitr2$l6v$1@newscl01ah.mathworks.com>...
> I normalize my data that have zero mean and unit variance
> sgn=(sgn-mean(sgn(:)))/std(sgn(:));
> I did for both original signal and sample one;
> still gives me the value between -50 to 50;
=============

Is your process wide sense stationary? Why should taking the mean and std across time samples be the same as the statistical mean and std of the signals?

Also, xcorr does discrete summing (similar to discrete convolution). If you want this to approximate an integral or an expectation operator, you have to weight the result by an appropriate integration measure.

Subject: Correlation

From: dpb

Date: 29 Jun, 2012 02:12:33

Message: 5 of 6

On 6/28/2012 8:52 PM, Matt J wrote:
> "Hamdullah YOKUS" <hamdullahyokus@gmail.com> wrote in message
> <jsitr2$l6v$1@newscl01ah.mathworks.com>...
>> I normalize my data that have zero mean and unit variance
>> sgn=(sgn-mean(sgn(:)))/std(sgn(:));
>> I did for both original signal and sample one;
>> still gives me the value between -50 to 50;
> =============
>
> Is your process wide sense stationary? Why should taking the mean and
> std across time samples be the same as the statistical mean and std of
> the signals?
>
> Also, xcorr does discrete summing (similar to discrete convolution). If
> you want this to approximate an integral or an expectation operator, you
> have to weight the result by an appropriate integration measure.

I presume he wants the 'coef' option (optional argument) that normalizes
the lag 0 coefficient to unity.

doc xcorr % discusses the normalizations used ('none' is default)

--

Subject: Correlation

From: Yash

Date: 30 Jun, 2012 12:39:14

Message: 6 of 6

for that your require correlation coeefiicent but still this coeeficint does not give similarity

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us