help-octave
[Top][All Lists]
Advanced

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

Using the unique command without sorting the values and getting the rows


From: RT
Subject: Using the unique command without sorting the values and getting the rows
Date: Tue, 14 Jun 2016 19:49:42 -0400

Greetings

I'm trying to get all the rows based on the unique values found in the second column.  see example below
The index of the rows that I would keep would be row 1,2,3,5,7 (in that order)
I was thinking of using unique([5 5 3 4],'stable') (the 'stable' option seems to keep the
index value order without sorting), but octave 4 doesn't have the stable option how can a work around this

Example array:

C=[
1, 103.4025175681402,    103.4104224840438,    0.007904915903608867;
2, 102.1231938014567,    102.1146017352405,    0.00859206621620956;
3, 97.5338137548381,    97.53996181901071,    0.006148064172606382;
4, 97.54468038366592, 97.53996181901071,    0.004718564655206592;
5, 93.76199482417094,    93.77030145885571,    0.008306634684771552;
6, 93.77539643924416,    93.77030145885571,    0.005094980388449244;
7, 106.976493571217,    106.9837463671074,    0.007252795890309471]

The final array I'm trying to get
D=
[
1, 103.4025175681402,    103.4104224840438,    0.007904915903608867;
2, 102.1231938014567,    102.1146017352405,    0.00859206621620956;
3, 97.5338137548381,    97.53996181901071,    0.006148064172606382;
5, 93.76199482417094,    93.77030145885571,    0.008306634684771552;
7, 106.976493571217,    106.9837463671074,    0.007252795890309471];

Please note this is just an example there will be hundreds of rows.
PS: I'm using octave 4.0 on ubuntu 64bit 16.04
Thanks

reply via email to

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