Error "std::exception" with function textscan in Matlab 2013b
2 ビュー (過去 30 日間)
古いコメントを表示
Hi everybody, i have a file Text.txt with following sepecified content:
!typ truck,bus,car,motor,bicycle
!end typ
!allowed car,motor,bicycle
!end allowed
I want to get the string "car,motor,bicycle" from the row "!allowed car,motor,bicycle". So I did these in MATLAB 2012b:
io_contents = fullfile( 'Text.txt'); % open Textfile
Text = fileread( io_contents ); % read the content of io_contents
Rowbegin = strfind(Text,'!allowed'); find the beginn of the row in Text
Rowend = strfind(Text,'!end allowed')-3 ; find the end of the row in Text
Row = Text(Rowbegin:Rowend)
String = textscan(Row,'!allowed%s ');
String = String{1}{1}
it should work in Matlab 2012b,but in matlab 2013b it shows this message:
Caught "std::exception" Exception message is: invalid string position
at line 6 , where textscan used is.
Could you tell me the reason, and how could I solve it. Is the an alternativ functioini for the function textscan ? Thanks a lot
0 件のコメント
回答 (1 件)
Walter Roberson
2014 年 1 月 1 日
It would make more sense to use regexp() for that purpose.
String = regexp(Row, '(?:^!allowed\s+)\S+', 'match');
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Text Files についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!