how to identify the particular element and its position in matlab?

I have
f=[1 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 1 0 1 0 0 0 11 2 4 6 2 10 1];
In this f size is 1×35 . I want the answer as, at which positions 1 are present up to length 28.

回答 (1 件)

Stephen23
Stephen23 2016 年 1 月 10 日
編集済み: Stephen23 2016 年 1 月 10 日

0 投票

>> find(f(1:28)==1)
ans =
1 6 11 14 17 23 25
You also might like to do the introductory tutorials, which are a good way for beginners to learn basic MATLAB usage and concepts like this:

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

質問済み:

2016 年 1 月 10 日

編集済み:

2016 年 1 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by