help-octave
[Top][All Lists]
Advanced

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

Re: splitting array based on negative and positive values


From: Paul Perry
Subject: Re: splitting array based on negative and positive values
Date: Thu, 19 Jan 2012 11:34:59 -0500

ta = [ 1,2,-3  % ta a test array
2,3,4
5,6,-7
8,9,-10
11,12,13]

>> ta((ta(:,3) > 0),:)
ans =

    2    3    4
   11   12   13

>> ta((ta(:,3) < 0),:)
ans =

    1    2   -3
    5    6   -7
    8    9  -10

Note however that there is a distinction between 0 and -0 and the above won't make that distinction.  You likely don't need it but you would have to do something differently to distinguish 0 and -0 .

Hope this helps.

On Thu, Jan 19, 2012 at 11:16 AM, Rick T <address@hidden> 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

I'm using Octave 3.2.4 running under ubuntu 10.04 64bit
Thanks


_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave



reply via email to

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