textscan error - name-value pair arguments must come in pairs

13 ビュー (過去 30 日間)
Ihiertje
Ihiertje 2017 年 6 月 20 日
回答済み: Walter Roberson 2017 年 6 月 21 日
Hi,
I keep getting the following error:
Error using textscan
Name-value pair arguments must come in pairs.
fid = fopen(char(name),'r');
disp(name);
line = fgetl(fid);
line = fgetl(fid);
EID = sscanf(line,'%s');
line = fgetl(fid);
line = fgetl(fid);
A = textscan(line,'%s','%\t');
FlEx = str2num(cell2mat(A{1,1}(5)))
line =
Fluorescence excitation wavelength (nm): 405
Does someone know how to solve this problem?
  3 件のコメント
Ihiertje
Ihiertje 2017 年 6 月 21 日
編集済み: Ihiertje 2017 年 6 月 21 日
Hi Julian,
I looked at the documentation of textscan, but it did not help me in solving this problem. A textfile is generated with all my measurements and some parameters. And yes, I want to extract the wavelength (405) from the line. However, I do not understand why it is not possible with this code.
Adam
Adam 2017 年 6 月 21 日
It isn't possible for the reason the error message says. There is no syntax of textscan that matches yours.
At a guess you maybe meant:
A = textscan(line,'%s', 'Delimiter', '%\t');

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

採用された回答

Jan
Jan 2017 年 6 月 21 日
This line fails:
A = textscan(line,'%s','%\t');
What is the prupose of the two parameters? You did not explain them and they are not correct, therefore we cannot know the intention of the code.
The usage of textscan is explained exhaustively in the documentation:
doc textscan
If you do not understand some parts, please ask a specific question. Perhaps you want:
A = textscan(line, '%s', 'CommentStyle', '%', 'Delimiter', '\t');
But this is a guess only.
  2 件のコメント
Ihiertje
Ihiertje 2017 年 6 月 21 日
The idea is to give every word/number his own row. Then I can easily define which row I need for further calculation.
Jan
Jan 2017 年 6 月 21 日
編集済み: Jan 2017 年 6 月 21 日
@Iris: I do not see, how this explains the purpose of the argument '%\t'. As the error message says, this string is not accepted, because you need a Name-Value pair. I guessed that the '%' might be meant as comment character and the '\t' as separator.

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 6 月 21 日
A = textscan(line, '%*[^:]:%d');

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by