Importing text file data?
Mostrar comentarios más antiguos
Hello everyone,
I have written a function that imports .txt files and removes the 5 header lines. Right now the function only reads .txt files with 6 columns of data. I am trying to make this file more robust, so that it can read .txt files with any number of data columns up to say 12. I am not sure how to appproach this and was looking for some help in doing so. Here is my function:
function[data]=Load_Data(filename,strain_command_data)
FID=fopen(filename);
data=textscan(FID,%f%f%f%f%f%f','HeaderLines',5,'CollectOutput',1);
fclose(FID);
data=data{1}
rows_remove=find(data(:,strain_command_data)==0);
if (~isempty(rows_remove)),
data=data(1:rows_remove(1)-1,:);
end
end
Any help would be great.
1 comentario
per isakson
el 14 de Nov. de 2013
Did you search the File Exchange for ideas?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Text Files en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!