MATLAB: Matrix value comparision and manipulation

arraycompMATLABmatricesmatrixmatrix arraymatrix manipulation

i have a matrix C=
21 14 7 0
18 11 4 3
15 8 1 6
12 5 2 9
9 2 5 12
6 1 8 15
3 4 11 18
0 7 14 21
smallest element amongst the rows: D= 0 3 1 2 2 1 4 0
Smallest element amongst columns: E= 0 1 1 0
whenever the 1st element of E is matched with first element of D ,then assign 1, then the 2nd element of E should match 2nd element of D, if not assign 0.then 2nd element of E which is not yet matched is compared with 3rd element of E & so on.
FINAL OUTPUT : 1 0 1 0 0 1 0 1

Best Answer

C=[21 14 7 0
18 11 4 3
15 8 1 6
12 5 2 9
9 2 5 12
6 1 8 15
3 4 11 18
0 7 14 21];
D=min(C')
E=min(C);
result=ismember(D,E)
#Final_Output:
result =
1×8 logical array
1 0 1 0 0 1 0 1