[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to extract sequenced data from an array?
From: |
veryhappy |
Subject: |
Re: How to extract sequenced data from an array? |
Date: |
Thu, 23 Dec 2010 08:36:53 -0800 (PST) |
What about this procedure (warning: It's slooooow):
% We create a random vector
a=round(rand(1,2124)*2);
% Then we repeat it several times and a little more (period=2124)
a=[a,a,a,a,a,a,a(1:2)];
% We find every repetition of first element and discard itself
% Any of those can be the period
ind=find(a==a(1));
ind(1)=[];
[tam]=length(a);
period=0;
for tmp=ind
tmp=tmp-1;
% We must calculate how many times we need to repeat the chunk to fill the
matrix
ntimes=ceil(tam/tmp);
% Then we create the filled matrix and cut the excess.
% If it's equal to the initial matrix then we found the period
if(isequal(a,resize([repmat(a(1:tmp),1,ntimes),a(tmp)],1,tam)))
period=tmp;
break;
endif
endfor
period
--
View this message in context:
http://octave.1599824.n4.nabble.com/How-to-extract-sequenced-data-from-an-array-tp3160358p3162279.html
Sent from the Octave - General mailing list archive at Nabble.com.
- Re: How to extract sequenced data from an array?, (continued)
- Re: How to extract sequenced data from an array?, Francesco Potortì, 2010/12/23
- Re: How to extract sequenced data from an array?, Sergei Steshenko, 2010/12/22
- Re: How to extract sequenced data from an array?, new_user, 2010/12/22
- Re: How to extract sequenced data from an array?, Doug Stewart, 2010/12/22
- Re: How to extract sequenced data from an array?, Przemek Klosowski, 2010/12/22
- Re: How to extract sequenced data from an array?, Kim Hansen, 2010/12/31
- Re: How to extract sequenced data from an array?, Ghostly, 2010/12/31
Re: How to extract sequenced data from an array?,
veryhappy <=