How to define a vector for multiple files
Mostrar comentarios más antiguos
I have a series of .txt tiles that all contain 3 columns; depth, temperature and salinity. I want to create a vector for depth, temperature and salinity for all of these files without individually writing out the names of each as there is a lot.
I tried to use the following script to accomplish this but get the error message 'index exceeds Matrix Dimensions'. Any help would be greatly appreciated.
files=dir('*.txt');
for i=1:length(files)
eval(['load ' files(i).name ' -ascii']);
end
Depth(:,1)=files(:,1);
Temp(:,1)=files(:,2);
Sal(:,1)=files(:,3);
1 comentario
Jos (10584)
el 19 de Feb. de 2014
files is a variable holding the names of the text files, not the contents of it. This is causing the error message.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Adding custom doc en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!