フィルターのクリア

How to count a character string position?

2 ビュー (過去 30 日間)
Emily
Emily 2022 年 4 月 25 日
回答済み: Stephen23 2022 年 4 月 25 日
I have a character string with 00101100
There is data where there is 1 and nothing in 0.
I wanted to it to display the places with the datas.
For example "The places with data are 3, 5, 6"

採用された回答

Stephen23
Stephen23 2022 年 4 月 25 日
S = '00101100';
X = strfind(S,'1');
fprintf('The places with data are %s\n',join(string(X),", "))
The places with data are 3, 5, 6

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 4 月 25 日
S = '00101100'
S = '00101100'
find(S == '1')
ans = 1×3
3 5 6

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by