Combining text with non-zero elements of a 2D array
I have a numerical array that is "almost" diagonal, so it looks like this:
N=[10 0 0 0 0; 0 20 0 0 0; 10 0 20 0 0; 0 0 0 10 0; 0 0 0 0 30]
I also have a cell array with the same number of rows, which looks like this:
C={‘ABC’;’DEF’;’GHI’;’JKL’;’MNO’}
I would like to create a row array that takes the non-zero values of N, and combines them with the text in C to give an output like this:
CN={‘ABC10_GHI10’ ‘DEF20’ ‘GHI10’ ‘JKL10’ ‘MNO30’}
In other words, it must combine all the non-zero values of each column with text of respective indices.I have a numerical array that is "almost" diagonal, so it looks like this:
N=[10 0 0 0 0; 0 20 0 0 0; 10 0 20 0 0; 0 0 0 10 0; 0 0 0 0 30]
I also have a cell array with the same number of rows, which looks like this:
C={‘ABC’;’DEF’;’GHI’;’JKL’;’MNO’}
I would like to create a row array that takes the non-zero values of N, and combines them with the text in C to give an output like this:
CN={‘ABC10_GHI10’ ‘DEF20’ ‘GHI10’ ‘JKL10’ ‘MNO30’}
In other words, it must combine all the non-zero values of each column with text of respective indices. I have a numerical array that is "almost" diagonal, so it looks like this:
N=[10 0 0 0 0; 0 20 0 0 0; 10 0 20 0 0; 0 0 0 10 0; 0 0 0 0 30]
I also have a cell array with the same number of rows, which looks like this:
C={‘ABC’;’DEF’;’GHI’;’JKL’;’MNO’}
I would like to create a row array that takes the non-zero values of N, and combines them with the text in C to give an output like this:
CN={‘ABC10_GHI10’ ‘DEF20’ ‘GHI10’ ‘JKL10’ ‘MNO30’}
In other words, it must combine all the non-zero values of each column with text of respective indices. cell arrays, combining text and numericals, non-zero element, find MATLAB Answers — New Questions