importdata

12 次查看(过去 30 天)
Danielle
Danielle 2011-12-1
Hello!
Im trying to read contents of a file using importdata When i execute txt_temp = importdata(files{nF}); and type
K>> txt_temp(1)
ans =
data: [1x31 double]
textdata: {2x327 cell}
It shows data and textdata as column 1 and column2 however when i use the same script on a different machine with the same version of matlab its not showing the data or text data and is showing in char.
[1x3268 char]
[1x5642 char]
The input data is exactly the same and im not sure whats going on. Any help would be greatly appreciated. Thankyou!
files = textread ('/Users/test.txt','%s', 'delimiter', '\n');
names = cell(1, length(files));
for nF = 1:length(files)
txt_temp = importdata(files{nF});
names{nF} = txt_temp.textdata{2};
txt_temp=txt_temp.textdata(2,:);
txt_temp = txt_temp(2:end);
end
P.S For example test.txt has paths of 10 different files which look like
Columns s1 s2 s3 s4
GA 2.223455 0.412121 0.6777777 0.222333
  1 个评论
bym
bym 2011-12-2
maybe you can post a few lines of test.txt ?

请先登录,再进行评论。

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2011-12-2
What is the difference between these two computers, PC and non-PC? When you copy the files from one computer to another, do they go through some types of PC format / Unix format conversion? It looks like the carriage returns (or newlines) in the text files are removed in the latter case, thus the whole file is read in as two char arrays.

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by