Finding values in a matrix with logical operation
1 次查看(过去 30 天)
显示 更早的评论
Hi
I know how to show for a Matrix A the values in the first column which fullfill a certain condition. Say:
A =
8 1 6
3 5 7
4 9 2
Then I could use for displaying all the values bigger then 3 in the first column the following line:
A(A(:,1) > 3)
But what line do I use, if I want to display the values in the second column which are bigger than say "3"?
Thanks
1 个评论
Matt J
2013-1-9
编辑:Matt J
2013-1-9
Then I could use for displaying all the values bigger then 3 in the first column the following line: A(A(:,1) > 3)
While this would work in the case of the first column, it is cleaner to specify the column number explicitly not just in the indexing expression, but also in the look-up expression
A(A(:,1) > 3, 1 )
It's also easier to see how to generalize it to other columns, as Jan has showed you.
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!