MATLAB: From a matrix, Pick one element from each row and not from same column for all possibilities. Only for non zero elements.

pick one element from each row and not from same column

Hi, From a matrix, I would like to pick one element from each row and not from same column for all possibilities.
Only for non zero elements.
Example, from A = [1 2 0; 1 2 0; 0 0 3], I want to obtain (1 2 3 and 2 1 3).
Thank you

Best Answer

Hi,
Your requirements are answered in a similar question mentioned in this link. Also, selecting set of elements from a matrix such that each element comes from distinct row and column can also be modeled as a Matching problem. (graph theory)