How to find row values?
显示 更早的评论
Hello everyone, I have a matrix a = [3 2 1; -5 0 6; 0 0 7], where I know the maximum value in the matrix is 7. I want to know the respective row values of the 7, i.e 1,6 and the new matrix b =[1 6 7](the row of the maximum value 7).Please help me with code.
I appreciate your help, TIA, Ketan
采纳的回答
更多回答(1 个)
Andrei Bobrov
2017-6-21
for 2d arrays
a = [3 2 1; -5 0 6; 0 0 7];
[~,c] = max(max(a));
b = a(:,c)
类别
在 帮助中心 和 File Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!