I want to retrieve a subset from a matrix A based on it's value.
For example, from matrix A (see below), I want to get the rows where the first column value equals 9 Expected output:
{ 9, 12, 21 },
{ 9, 13, 23 },
{ 9, 14, 24 },
Array<double> A = new double[,] {
{ 1, 9, 20 },
{ 2, 11, 21 },
{ 9, 12, 21 },
{ 9, 13, 23 },
{ 9, 14, 24 },
{ 6, 15, 25 }
};
Array<double> test1 = A[A[0] == 9];
Array<double> test2 = A[A == 9];
///Get the first column
Array<double> D = A[full, 0];
///test 3: Get all rows where the value for the first column is 9
Array<double> match = D.Where(e => e == 9).ToArray();
///test 4:Get all rows where the value for the first column is 9 from A
Array<double> match2 = A.Where(e => e == 9).ToArray();
Without testing, I guess this should do the trick:
Array<double> match = A[A[full, 0] == 9, full];