Could anyone help me how to solve the issue
1 次查看(过去 30 天)
显示 更早的评论
I am having a matrix
A=[0.0088 0.0071 0.0058 0.0049 0.0045 0.0045;
0.0255 0.0248 0.0241 0.0234 0.0227 0.0218;
1.8321 2.0932 2.3378 2.5582 2.7400 2.8653;
0.0666 0.0605 0.0559 0.0526 0.0505 0.0491;
0.0322 0.0294 0.0303 0.0334 0.0372 0.0410]
to find the maximum value in each row i used the command max(A,[],2) which gives the result.
But i need to have the output in such a way that the matrix needs to be displayed holding only the maximum value and rest of the other values should be zero.
Could anyone please help me on this.
0 个评论
采纳的回答
madhan ravi
2019-7-31
编辑:madhan ravi
2019-7-31
[v,idx] = max(A,[],2);
Wanted = zeros(size(A));
Wanted(sub2ind(size(A),(1:size(A,1)).',idx)) = v
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!