Re: circular shifting a vector/matrix - Problem
- From: "jkvdpoel" <jkvdpoel@xxxxxxxxx>
- Date: 30 Apr 2006 20:06:32 -0700
Jos wrote:
jkvdpoel wrote:
< SNIP circshift to slow ...
Here you have a piece of my code:
corrCoef = zeros(1, numColMatrix01);
for shiftSize = 1:numColMatrix01,
corrCoef(shiftSize) = corr2(Matrix01, Matrix02);
Matrix01 = circshift(Matrix01, [0 shiftSize]);
Are you sure you want to shift like this (iteration 1, 1 shift,
iteration 2, 2 shifts of the already shifted (!!) matrix)? Probably
not ...
Using indexing may be much faster.
for i=1:size(M1,2),
C = corr2(M1,M2) ;
M1 = M1(:,[2:end 1]) ; % shift columns
end
or more directly
nc2 = size(M1,2) ;
for i = 1:nc2,
C(i) = corr2(M1(:,[i:nc2 1:(i-1)]),M2) ;
end
hth
Jos
Hi, Jos (and all the others who kindly anwered to my question):
Quoting you,
Are you sure you want to shift like this (iteration 1, 1 shift,
iteration 2, 2 shifts of the already shifted (!!) matrix)? Probably
not ...
Suddenly, and _many_ thanks to your message, I realised that this was
_not_ what I really wanted. I wanted something like this: (iteration 1,
1 shift, iteration _2_, _1_ shift of the already shifted matrix,
iteration _3_, _1_ shift of the already shifted matrix, ...). But the
question remains (because it is still burning my brain)...
Does your solution is related to my question or is related to your
point of view (the one that "was _not_ what I wanted")? Could you
clarify this for me, please?
Many thanks in advance for you and all the other who answered so fast
to my question,
JanKees Poel
.
- Follow-Ups:
- Re: circular shifting a vector/matrix - Problem
- From: Roger Stafford
- Re: circular shifting a vector/matrix - Problem
- References:
- Prev by Date: Re: How can I import the data from Excel
- Next by Date: Re: Plot Multiple Images on One Plot
- Previous by thread: Re: circular shifting a vector/matrix - Problem
- Next by thread: Re: circular shifting a vector/matrix - Problem
- Index(es):
Relevant Pages
|