help in adding a descending order a symetric matric
Mostra commenti meno recenti
Hello! I want to put in a descending order just the part upper the main diagonal in a symmetric matrix and to get the index of those elements. What should I change in this code?
function [values,i,j] = max(A,n)
[a, linIdx] = sort(A(:),'descend');
values = a(1:n);
[i,j] = ind2sub(size(A),linIdx(1:n));
1 Commento
Walter Roberson
il 17 Gen 2017
Please do not call your function "max" as that interferes with using the key MATLAB routine "max"
Risposta accettata
Più risposte (1)
Walter Roberson
il 17 Gen 2017
1 voto
See https://www.mathworks.com/matlabcentral/newsreader/view_thread/278808 for information on extracting the upper diagonal.
However, the question arises of which index you are looking for. Are you looking for an index relative to the vector of extracted values, or are you looking for the index into the original matrix?
1 Commento
ana take
il 17 Gen 2017
Categorie
Scopri di più su Linear Algebra in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!