I am attempting to reorder the rows of a matrix from greatest number of nonzero elements to least. I calculate the number of zeros per row and then sort that variable to get the correct order, but I am having tourble using my sorted variable to reorder the original matrix. I have posted what I have so far below
Index_matrix = [42 33 27 22 17 12 7 4 2 1 043 34 26 21 16 11 6 3 1 0 044 35 28 22 17 12 7 4 2 1 045 36 29 23 18 13 8 2 1 0 046 37 30 24 19 14 9 3 1 0 047 38 31 25 20 15 10 5 2 1 048 39 32 26 21 16 11 6 3 1 049 40 33 27 22 17 12 7 4 2 150 41 31 25 20 15 10 5 2 1 0]; test = sum(Index_matrix==0, 2); test2 = sort(test,1); index_matrix = sort(Index_matrix, test2);
Best Answer