# Extracting segents of data from array

7 messages
Open this post in threaded view
|

## Extracting segents of data from array

 I have a large array that I want to extract specific rows from. Specifically I want to extract data from every 9th row as well as the one before and the one after starting at the 100th row.  What is the quickest way to do this? Thanks
Open this post in threaded view
|

## Re: Extracting segents of data from array

 Administrator On Jan 3, 2011, at 1:13 PM, lciotti wrote: > I have a large array that I want to extract specific rows from. > > Specifically I want to extract data from every 9th row as well as the one > before and the one after starting at the 100th row.  What is the quickest > way to do this? > > Thanks If your original array is "a" ...         n = 100:9:rows(a);         n = union (union (n, n-1), n+1);         b = a(n,:); ... "b" contains the extracted data. Ben _______________________________________________ Help-octave mailing list [hidden email] https://mailman.cae.wisc.edu/listinfo/help-octave
Open this post in threaded view
|

## Re: Extracting segents of data from array

 In reply to this post by lciotti On 3 January 2011 12:13, lciotti <[hidden email]> wrote: > I have a large array that I want to extract specific rows from. Octave doesn't really have arrays... I mean, internally it does, but the basic data type exposed at the interpreter is a matrix. It makes a subtle difference. For example, matrices don't nest like arrays do, a matrix cannot contain another matrix, at least not in the same way that an array can contain or point to other arrays. An array is usually immutable in size (at least, that's how C and C++ interpret the word "array") but Octave matrices are highly mutable in size and shape. I say these things as a warning lest you take the comparison between array and matrix too far. I have seen people do this and be surprised when [[["h"],["e"]],[[["llo"]]]] == "hello", for example. I see Ben has given you a solution for the rest of your question as I was writing this, so I'll omit the rest of the response I was preparing. - Jordi G. H. _______________________________________________ Help-octave mailing list [hidden email] https://mailman.cae.wisc.edu/listinfo/help-octave
Open this post in threaded view
|

## Re: Extracting segents of data from array

 Thanks for the quick and accurate response.  Now another question.  Is there a way to identify the rows that are greater than a given value? Say I want to know all the row numbers greater than 0.25. _______________________________________________ Help-octave mailing list [hidden email] https://mailman.cae.wisc.edu/listinfo/help-octave
Open this post in threaded view
|

## Re: Extracting segents of data from array

 Administrator On Jan 3, 2011, at 3:23 PM, Louis Ciotti wrote: > Thanks for the quick and accurate response.  Now another question.  Is > there a way to identify the rows that are greater than a given value? > > Say I want to know all the row numbers greater than 0.25. Assuming your array has multiple rows and one column ...         m = find (a > 0.25); If your array has multiple rows and columns, the rows with one or more elements larger than 0.25 ...         m = find (any (a.' > 0.25)); If you want the rows and columns for elements larger than 0.25 ...         [m, n] = find (a > 0.25); Ben _______________________________________________ Help-octave mailing list [hidden email] https://mailman.cae.wisc.edu/listinfo/help-octave