indexing for a single for loop of an upper triangular matrix

3 vues (au cours des 30 derniers jours)
Ryan
Ryan le 26 Avr 2013
Hello everyone,
I had a question and was wondering if it is even possible. I want to create a square matrix using some comparison function. The matrix is symmetric by nature of this function. I want to write the comparisons using a single for loop but only want the for loop to use the indices of an upper triangular matrix. How would I do this in matlab? Thank you in advance.

Réponses (1)

Matt J
Matt J le 26 Avr 2013
Modifié(e) : Matt J le 26 Avr 2013
If U is the upper-triangular matrix,
Iset=nonzeros(triu( reshape(1:numel(U), size(U)) ));
for i=Iset
....
end

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by