Sum of elements of a matrix such that no row or column repeats
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Lovish Goyal
am 21 Mai 2021
Kommentiert: Torsten
am 21 Mai 2021
If i choose an element of a matrix than the next element used should be from different row and different column. If there is a nxn matrix then the sum of n elements of the matrix should come from the elements of different row and different column.
0 Kommentare
Akzeptierte Antwort
Torsten
am 21 Mai 2021
p = randperm(n);
sum = 0.0;
for k = 1:n
sum = sum + a(k,p(k));
end
where a is the nxn matrix.
4 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!