I'm pretty new to matlab, so this may not make the most sense. I'm trying to scan a variable for where a particular string of 1s and 0s begin. Is this at all possible?
A little background: The string is 1023 bits in length, and the variable being scanned is 20000000 bits in length. This string should theoretically repeat itself 1e9 times in the variable being scanned. Anything helps, thanks!

回答 (1 件)

Star Strider
Star Strider 2019 年 6 月 13 日

0 投票

Try this example:
x = randi([0 1], 1, 100)
idx = strfind(num2str(x, '%d'), '101101')
I’m not exactly certain what you want to do. This is one option.

1 件のコメント

Walter Roberson
Walter Roberson 2019 年 6 月 14 日
If the "string" happens to be numeric, then you can use
idx = strfind(x, [1 0 1 1 0 1])

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Characters and Strings についてさらに検索

タグ

質問済み:

2019 年 6 月 13 日

コメント済み:

2019 年 6 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by