help-octave
[Top][All Lists]
Advanced

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

Re: Reverse concatenation?


From: Dmitri A. Sergatskov
Subject: Re: Reverse concatenation?
Date: Thu, 12 Jun 2008 11:30:32 -0500

On Thu, Jun 12, 2008 at 10:42 AM, Emily Moberg <address@hidden> wrote:
> Sorry! So, if i have a matrix like this A=[6;1;2;3;4;6;3;3;3;6] I would like
> to be able to access the values between the 6's as matrices on their own, so
> B=[1;2;3;4], C=[3;3;3]. I'm a really new user to octave so I really have no
> idea if this is even possible.  Thanks so much for your time.
>

There is no built-in function that would do that, but it is fairly
easy to code one.

idx = find(A==6)

will return index of your "separators" in matrix A.

Then something like:

 for n = 1:length(idx)-1; c{n} = A((idx(n)+1):(idx(n+1)-1)); endfor

will return a cell array each element c{n} would be a vector of data
between the separators.

Hope that helps.

Dmitri.
--


reply via email to

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