How to find the position of the first non-zero element of my matrix?

49 Ansichten (letzte 30 Tage)
Leon
Leon am 10 Mär. 2020
Kommentiert: Leon am 10 Mär. 2020
For example, if I have a column data like the below:
A = [0; 1; 0; 0; 0];
The answer would be 2.
For the below example:
B = [ 0; 0; 1; 0; 1; 0; 0];
The answer would be 3.
Is there a function to do that quickly?

Akzeptierte Antwort

Stephen23
Stephen23 am 10 Mär. 2020
Bearbeitet: Stephen23 am 10 Mär. 2020
find(yourVector,1,'first')

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by