user1205030
user1205030

Reputation: 225

MATLAB: how to locate the nth appeared number in a loop?

For example,

for i = 1:10

x = i + 2

s(1:i) = (x > 4);

result s = [0 0 0 1 1 1 1 1 1 1]'

how to located the column and row of the first "1" appeared in s?

Look for a script.

Thanks!!

Upvotes: 0

Views: 78

Answers (1)

High Performance Mark
High Performance Mark

Reputation: 78364

For a vector like s it's easy

find(s==1,1)

should do what you want.

Upvotes: 1

Related Questions