From: Mark Shore on
"Mark Shore" <mshore(a)magmageosciences.ca> wrote in message <hpsfvm$rtp$1(a)fred.mathworks.com>...
> A more appropriate signal to examine cross-correlation the way I'm guessing Michal wants would be something along the lines of :
>
> k=400; m=10; n=20; p=50;
> % m sine wave cycles with n samples/cycle padded with k leading and trailing zeros
> CH1=[zeros(1,k) repmat(sin(2*pi/n*(1:n)),1,m) zeros(1,k)];
> % shift CH1 by p sample intervals
> CH2=[CH1(p:end) CH1(1:p-1)]; % no 1D equivalent of circshift in MATLAB(?)
> plot(CH1,'b'); hold on; plot(CH2,'r'); hold off % optional plot
>
> He should also consider the limiting case of a vector with a single non-zero value, say [1 zeros(1,999)] and its cross-correlation with a shifted equivalent.

I thought a bit more carefully about how to use circshift.

k=400; m=10; n=20; p=50; % just examples
% m sine wave cycles with n samples/cycle padded with k leading and trailing zeros
CH1=[zeros(1,k) repmat(sin(2*pi/n*(1:n)),1,m) zeros(1,k)];
CH2=circshift(CH1',p)'; % shift CH1 by p sample intervals
plot(CH1,'b'); hold on; plot(CH2,'r'); hold off % optional plot
First  |  Prev  | 
Pages: 1 2 3 4
Prev: READING TEXT BOX VALUE....
Next: Bilevel optimization