Clear Filters
Clear Filters

How to detect ones and its location in a column

1 view (last 30 days)
I have matrix A,
A= [0 0 0 0 0 1 1 0 0 0]
How can I detect the ones in the vector and also its location in a column?
The result should be
location = [6 7]

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 19 Nov 2018
Edited: Andrei Bobrov on 19 Nov 2018
in your case (for vector):
location = find(A);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!