How do I locate similar values in different vectors?
Ältere Kommentare anzeigen
a=[1 4 26 27 41 0 0 0 0 0 0 0;
2 22 23 41 0 0 0 0 0 0 0 0;
4 55 77 0 0 0 0 0 0 0 0 0;
3 6 88 91 0 0 0 0 0 0 0 0]
My matrix's size is 4000x4000, but for simplicity let's take a look at matrix a above. I look at each row as a vector of numbers (usually followed by zeros, which are irrelevant for the task at hand). If there are any (nonzero) values recurring in different rows, I want to concatenate those rows. For matrix a above, I would like to receive: a=[1 2 4 22 23 26 27 41 55 77 0 0; 3 6 88 91 0 0 0 0 0 0 0 0] (after using "unique" on the concatenated vectors). How do I locate recurring values in different rows without using for loops within for loops?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!