フィルターのクリア

Finding the first occurance of a given string

20 ビュー (過去 30 日間)
UWM
UWM 2016 年 11 月 10 日
コメント済み: UWM 2016 年 11 月 11 日
I have a large text file in which I need to find the first occurance of a given string, e.g. 'STAX'. How can I do this?

採用された回答

KSSV
KSSV 2016 年 11 月 11 日
編集済み: KSSV 2016 年 11 月 11 日
fid = fopen('filename','r') ;
S = textscan(fid,'%s','Delimiter','\n');
S = S{1} ;
%%Get the line number of your string 'STAX'
idxS = strfind(S,'STAX'); % find the index of your string
idx = find(not(cellfun('isempty',idxS))); % your required indices
S(idx)
  1 件のコメント
UWM
UWM 2016 年 11 月 11 日
Thank you very much for help :)

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

その他の回答 (0 件)

カテゴリ

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