thanks
I have a code but now sure how it works please help
1 view (last 30 days)
Show older comments
[C,I]=max(sum(a,2));
can some body explain how variables C and I change in 3x3 matrix. thanks in advance
Accepted Answer
Geoff Hayes
on 8 Oct 2014
Etan - is a the 3x3 matrix that you are referring to? If it is, then
sum(a,2)
calculates the sum of each row, returning a 3x1 column vector. Then
[C,I]=max(sum(a,2));
will set C to the max element in that 3x1 vector, with I the index of that max element in the vector (so a value between 1 and 3, since there are three rows).
0 Comments
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!