help-octave
[Top][All Lists]
Advanced

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

splitting array based on negative and positive values


From: John W. Eaton
Subject: splitting array based on negative and positive values
Date: Thu, 19 Jan 2012 11:34:51 -0500

On 19-Jan-2012, Rick T wrote:

| Greetings All
| 
| I have and array and I'm trying to split out rows based on the positive and
| negative values in the 3rd column into their own separate arrays
| I know I can do a sortrows on the 3rd column but how does one split out rows
| based on the the negative and positive values of the 3rd column into there own
| array.
| 
| Example of array:
| 1,2,-3
| 2,3,4
| 5,6,-7
| 8,9,-10
| 11,12,13
| 
| 1st array split
| 1,2,-3
| 5,6,-7
| 8,9,-10
| 
| 2nd array
| 2,3,4
| 11,12,13

  x = [1,2,-3; 2,3,4; 5,6,-7; 8,9,-10; 11,12,13];
  neg_idx = x(:,3) < 0;
  x(neg_idx,:)
  x(!neg_idx,:)

jwe


reply via email to

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