0/0
ans =
NaN
Since corr(A, B) = cov(A,B)/(std(A) *std(B)) when you have that the two segments are all zeros, then you will get NaN.
You cannot avoid it but you can decide that the NaN is informative in that case.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!