importdata

10 vues (au cours des 30 derniers jours)
Danielle
Danielle le 1 Déc 2011
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 commentaire
bym
bym le 2 Déc 2011
maybe you can post a few lines of test.txt ?

Connectez-vous pour commenter.

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 2 Déc 2011
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.

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by