Error using textscan. Delimiter must be a string.

5 ビュー (過去 30 日間)
luckyRadar
luckyRadar 2014 年 1 月 21 日
コメント済み: Gregory 2014 年 6 月 2 日
The code works for 2013a, however when I run on 2012a the following is reported:
Error using textscan
Delimiter must be a string.
Working 2013a code:
delimiter = {' : ',' (D',' (K'};
dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', delimiter, 'MultipleDelimsAsOne', true, 'EmptyValue' ,NaN,'HeaderLines', startRow(1)-1, 'ReturnOnError', false);
I am struggling to translate the delimiter. Note, the defined delimiter is for 3 cases:
Case1 space:space
Case2 space(D
Case3 space(K
Thanks! Appreciate your time.

採用された回答

Walter Roberson
Walter Roberson 2014 年 1 月 21 日
R2012a did not support a cell array of delimiter strings for textscan.
You might need to break the lines apart some other way, such as by using regexp()
  2 件のコメント
luckyRadar
luckyRadar 2014 年 1 月 21 日
Walter,
Thanks. I figured that was the answer, but wanted to verify I was not missing something. Thanks again.
Gregory
Gregory 2014 年 6 月 2 日
Why doesn't the documentation mention that? When you look up textscan it says:
Field delimiter characters, specified as the comma-separated
pair consisting of 'Delimiter' and a string or
a cell array of strings.
Specify multiple delimiters in a cell array
of strings.
Example: 'delimiter',{';','*'}
With no quailifers on version.

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

その他の回答 (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