I need to read a file and store the values, so I can call these values in a for loop.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Allen Hammack
el 28 de Feb. de 2017
Respondida: Allen Hammack
el 28 de Feb. de 2017
I have a file (names.txt) that is a list of file names. There is one file name per line. I need to read that file, so that each file name can be used in a for loop. I've tried to read the file as multiple strings with fscanf, but I get all the file names concatenated into one single string. How can I read the file into a single column array?
0 comentarios
Respuesta aceptada
KSSV
el 28 de Feb. de 2017
fid = fopen('your txt file') ;
S = textscan(fid,'%s','delimiter','\n') ;
S = S{1} ;
fclose(fid) ;
for i = 1:length(S)
S{i}
end
0 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!