Textscan syntax disagreement

11 次查看(过去 30 天)
I am using textscan to import a file. It has 40 columns, which means I use the following.
data = textscan(dataID, '%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f');
However I'd like to shorten this up a bit, and go with this instead.
data = textscan(dataID, '%f', 40);
Unfortunately the two return different values and I can't for the life of me figure out why.

采纳的回答

Walter Roberson
Walter Roberson 2012-5-21
thisfmt = repmat('%f', 1, 40);
data = textscan(dataID, thisfmt);
When you use '%f', 40, then you instruct textscan to use "%f" 40 times total, which would just get you your first line.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 NaNs 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by