How to produce substrings

Write a single MATLAB statement that will accomplish the stated purpose. Assume a text string TS1 has already been defined. Find all occurrences of the string @3G in string TS1 and place the locations of the first character of each such substring (@) into Str3G. Example: TS1='%@3Gb6kl@3G9@33G' returns Str3G=[2 9].

回答 (1 件)

Star Strider
Star Strider 2016 年 1 月 21 日

0 投票

Use strfind:
TS1='%@3Gb6kl@3G9@33G'
Str3G = strfind(TS1, '@3G')
Str3G =
2 9

カテゴリ

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

タグ

質問済み:

2016 年 1 月 21 日

回答済み:

2016 年 1 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by