Find the first element of a column in a matrix that has a value equal to zero

18 次查看(过去 30 天)
I have an m by n matrix and I'm interested in the nth column. Initially all of the values in the nth column are greater than zero. As the code executes, at some point, a specific row in the nth column will equal zero. I want to determine which row that is. One issue is that after this first instance of zero, all of the subsequent rows in the nth column will also equal zero. I just want the first row in the last column that has a value of zero.

采纳的回答

Dyuman Joshi
Dyuman Joshi 2021-6-3
r=find(A(:,n)==0,1) %A is your m by n matrix after executing the code

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by