for loop and "importdata" function
Afficher commentaires plus anciens
Hi. I hope some of you have time to help me with this one: I am trying to import some ascii-files with a 5 line header plus tab-separated numbers. I want to sum the tab-separated numbers only, and I have 200 files. The code I have written is:
clear;
files = dir('H:\testmappe_sletmig');
for i=1:length(files)
data = importdata(files(i).name, '\t', 6);
summarise = sum(data(:));
end
xlswrite(summarise_fetch,summarise);
However, I get an error message saying
"Error using importdata (line 215)
Unable to load file.
Use TEXTSCAN or FREAD for more complex formats.
Error in extractsum (line 8)
data = importdata(files(i).name, '\t', 6);
Caused by:
Error using fileread (line 27)
Could not open file .. Invalid argument."
Any help is much appreciated!
4 commentaires
Oleg Komarov
le 8 Août 2012
Is the file damaged or protected?
A Westergaard
le 8 Août 2012
per isakson
le 9 Août 2012
Can you import the files interactively with the Import Wizard? The [Import Data] button in the Workspace toolbar.
A Westergaard
le 9 Août 2012
Modifié(e) : A Westergaard
le 9 Août 2012
Réponse acceptée
Plus de réponses (1)
A Westergaard
le 9 Août 2012
Catégories
En savoir plus sur Workspace Variables and MAT Files dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!