Filter löschen
Filter löschen

Sum up dissimilar values in a matrix

2 Ansichten (letzte 30 Tage)
Anum Ahmed
Anum Ahmed am 15 Nov. 2019
Kommentiert: Anum Ahmed am 15 Nov. 2019
Hi All,
I have a 12*12 matrix and want to add the entries of matrix which are not equal to 1 and which are not similar to any other value in the Matrix. In short, I want to add up all the dissimilar values and the values not equal to 1.
Is there any short way to do so using loop function.
Many Thanks
Anum

Akzeptierte Antwort

the cyclist
the cyclist am 15 Nov. 2019
Bearbeitet: the cyclist am 15 Nov. 2019
If M is your array ...
sum(unique(M(M~=1)))
  3 Kommentare
the cyclist
the cyclist am 15 Nov. 2019
Sorry, meant to include the uniqueness in there. Edited to fix.
Anum Ahmed
Anum Ahmed am 15 Nov. 2019
Awesome. Thanks a bundle...
Regards
Anum

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by