Info
This question is closed. Reopen it to edit or answer.
How can I create a matrix with the results of a disp function?
1 view (last 30 days)
Show older comments
J = [0 3 4;3 0 8;4 8 0];
for i =1:numel(J)
[i,j] = ind2sub(size(J),find(triu(J==i)));
disp([i j])
end
I have the above code and as a result I get 1 2 ; 1 3; 2 3, which are the positions of the elements 3,4 and 8 respectively. I want to get the position in decreasing order, that is firstly for the 8--> 2-3,next for the 4--> 1-3 and lastly 3--> 1-2.
How can I create a matrix M having the form of:
M=[8 2 3
4 1 3
3 1 2]
Thank you in advance.
0 Comments
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!