0

Suppose I have the following matrices:

    >> A = [1 3 5;6 8 11]
    >> flagA=ones(size(A))
    >> B = [4;12]
    >> flagB=[2;2]
    >> C=[A,B]

Thus, matrices look like follows:

    A =

 1     3     5
 6     8    11

    flagA =

 1     1     1
 1     1     1

    B =

 4
12

    flagB =

 2
 2

    C =

 1     3     5     4
 6     8    11    12

I want to sort each row in C in increasing order, so we get

    sortedC =
 1  3  4  5
 6  8  11 12 

and get a flagC matrix that contains the corresponding the flagA and flagB elements in the sortedC matrix

    flagC =
 1  1  2  1
 1  1  1  2

I know how to sort each row in C to get sortedC. But how do we obtain the flagC matrix based on the sortedC matrix?

user3750170
  • 99
  • 3
  • 7

0 Answers0