How to sum and compare the similar elements of 3 rows????
Afficher commentaires plus anciens
I have a 5 by 5 matrix,
A=[1 1 1 0 1;
1 0 0 0 1;
1 1 0 0 1;
1 1 0 0 0;
0 0 0 1 1]
I want to sum 3 row elements randomly and count only when all three row elements are same otherwise no,for example,
rows: {1,3,4}=2
{2,4,5}=1
{1,4,5}=0
the three rows can be any 3 out of 5, it wont be having all combinations of 3 rows.
please please help me.... and please can you explain me that how will i take 3 rows. if i will compare 4 row element then what will be the coding. please please help me.
3 commentaires
Image Analyst
le 22 Avr 2015
Modifié(e) : Image Analyst
le 22 Avr 2015
I fixed your formatting but you can read this so you can do it yourself: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
I don't understand what a "row element" is. Is it an entire row, or just an element from the matrix. If you sum all numbers in rows 1, 3, and 4 you get 9, not 2.
the cyclist
le 22 Avr 2015
Can you look at my code below, and see if that does what you want?
I feel like it might be right, but I get 3 for {1,3,4} rather than 2.
suchismita
le 23 Avr 2015
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!