help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to extract sequenced data from an array?


From: Ben Abbott
Subject: Re: How to extract sequenced data from an array?
Date: Wed, 22 Dec 2010 08:39:53 -0500

On Dec 22, 2010, at 8:23 AM, new_user wrote:

> Hello Ben,
> 
> Wednesday, December 22, 2010, 1:43:27 PM, you wrote:
> 
>> I don't understand what is unique about the result you'd like to get.
> 
>> It looks to me like Y is identical to X, but truncated to 5 rows, Y = 
>> X(1:5,:)
> 
>> Assuming you'd like to find the unique values for each column of x ...
> 
>>        cellfun (@unique, mat2cell (X, rows(X),
>> ones(1,columns(X))), "uniformoutput", false)
> 
>> Ben
> 
> Sorry if my English is bad, but if example array isn't clear to read:
> I want unique sequence, not unique values - I want whole part of the
> array that is repeating:
> 
> A B C D D D A B C D D D A B C D D D
> |_________| |_________| |_________|
>     |           |           |
>   unique      unique      unique
>  sequence    sequence    sequence
>    data        data        data
> 
> I also tried your suggestion, which I suspect returns unique values,
> plus I want to process 2 dimensional array and get 2 dimensional array
> 
> Thanks for your reply

Someone with expertise in signal processing may have a solution, that is more 
efficient with time and/or memory.

function y = period (x)
  r = rows(x);
  p = 0;
  a = [];
  while (p < r && ! isequal (x, a))
    p = p + 1;
    y = x(1:p,:);
    a = repmat (y, ceil (r/p), 1)(1:r,:);
  endwhile
endfunction

Ben



reply via email to

[Prev in Thread] Current Thread [Next in Thread]