[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to extract sequenced data from an array?
From: |
Ghostly |
Subject: |
Re: How to extract sequenced data from an array? |
Date: |
Fri, 31 Dec 2010 18:39:17 +0100 |
Thanks for your replies
I tried your code and it works fine. My problem with it, is that when I use my
data (5 decimal point single column matrix) instead your random vector "a", I
get this error:
repmat: with 3 arguments m and n must be scalar
pointing to:
if(isequal(a,resize([repmat(a(1:tmp),1,ntimes),a(tmp)],1,tam)))
Cheers
> function period=find_period(a)
> % 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 the period can fit there
> ntimes=ceil(tam/tmp);
> % And then we check if the resulting matrix is equal
> if(isequal(a,resize([repmat(a(1:tmp),1,ntimes),a(tmp)],1,tam)))
> period=tmp;
> break;
> endif
> endfor
> endfunction
- Re: How to extract sequenced data from an array?, (continued)
- Re: How to extract sequenced data from an array?, Doug Stewart, 2010/12/22
- 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, 2010/12/23