using textscan

2 visualizaciones (últimos 30 días)
Richard
Richard el 23 de Feb. de 2012
Editada: Image Analyst el 22 de Oct. de 2013
Is textscan the correct command to use when importing data from text files into matlab. The command seems to work fine if I only have a vector in the text file, but if I have a matrix, matlab will change the structure of the data and store the matrix as a vector. Which command should I use if I'm importing data from text files within a loop where some of the text files include vectors and others include matrices?

Respuesta aceptada

Oleg Komarov
Oleg Komarov el 23 de Feb. de 2012
You have to specify the right 'format', read example 8 to get an idea: http://www.mathworks.co.uk/help/techdoc/ref/textscan.html
  3 comentarios
Richard
Richard el 23 de Feb. de 2012
I've decided to use dlmread seeing as the .txt files do not have any headings.
Oleg Komarov
Oleg Komarov el 23 de Feb. de 2012
Headers do not matter, if you want 4 columns the right format is:
textscan(fid,'%f %f %f %f','Delimiter',''whateveryoulike')
or
textscan(fid,'%f',4,'Delimiter',''whateveryoulike')

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by