From: Stefanie on
Thanks for the help.
I think I found the problem. I had -Inf and Inf values in my data vectors which seemed to confuse the corr2 function.
I changed that and now its working.


"Oleg Komarov" <oleg.komarovRemove.this(a)hotmail.it> wrote in message <hlec36$5or$1(a)fred.mathworks.com>...
> "Stefanie " <steffi_rulla(a)hotmail.com> wrote in message <hlebbg$g6h$1(a)fred.mathworks.com>...
> > Hi there,
> > I'm trying to correlate 2 signals with the functions corr2 or rather corrcoef.
> > I wrote a code for that but the resulting matricez are only composed out of NaNs. Is there a genral hint or solving this problem? I plotted the two signals on each other and there must be at least some correlation.
> > I'll appreciate any help!
>
> Yes, read the help carefully the 'rows' option of corrcoef.
> Example:
> In = [rand(4,1); NaN(4,1)];
> In = [In flipud(In)]
> In =
> 0.9575 NaN
> 0.9649 NaN
> 0.1576 NaN
> 0.9706 NaN
> NaN 0.9706
> NaN 0.1576
> NaN 0.9649
> NaN 0.9575
>
> As you can see in this extreme example the series don't have valid overlapping values.
> If you don't care you should first align them.
>
> Oleg
From: Oleg Komarov on
"Stefanie " <steffi_rulla(a)hotmail.com> wrote in message <hlebbg$g6h$1(a)fred.mathworks.com>...
> Hi there,
> I'm trying to correlate 2 signals with the functions corr2 or rather corrcoef.
> I wrote a code for that but the resulting matricez are only composed out of NaNs. Is there a genral hint or solving this problem? I plotted the two signals on each other and there must be at least some correlation.
> I'll appreciate any help!

Yes, read the help carefully the 'rows' option of corrcoef.
Example:
In = [rand(4,1); NaN(4,1)];
In = [In flipud(In)]
In =
0.9575 NaN
0.9649 NaN
0.1576 NaN
0.9706 NaN
NaN 0.9706
NaN 0.1576
NaN 0.9649
NaN 0.9575

As you can see in this extreme example the series don't have valid overlapping values.
If you don't care you should first align them.

Oleg
From: Wayne King on
"Stefanie " <steffi_rulla(a)hotmail.com> wrote in message <hlebbg$g6h$1(a)fred.mathworks.com>...
> Hi there,
> I'm trying to correlate 2 signals with the functions corr2 or rather corrcoef.
> I wrote a code for that but the resulting matricez are only composed out of NaNs. Is there a genral hint or solving this problem? I plotted the two signals on each other and there must be at least some correlation.
> I'll appreciate any help!

Hi stefanie, are you trying to produce the cross-correlation estimate of two 1D signals? If so, then you want to use xcorr

>>doc xcorr


Wayne