importing .txt file using textscan
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Good Afternoon, I am trying to import data from a text file in order to plot, and need help writing a scipt.
the text file has text as well as numerical data within it so the load function wont work.
I don't fully understand how the textscan function works, my text data has the first 4 rows with just text, and then the columnheaders in each column, (row 5). Every row past this is just space separated numerical data.
How would I write the command out as to import the data into a usable format to plot with? The data is seprated by spaces (no commas)
0 comentarios
Respuesta aceptada
Walter Roberson
el 4 de Abr. de 2012
fid = fopen('YourFile.txt','rt');
datacell = textscan(fid, '%f%f%f', 'HeaderLines',5);
fclose(fid);
After that, datacell{1} is a vector containing the first column, datacell{2} is a vector containing the second column, datacell{3} is a vector containing the third column.
4 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Data Import and Export en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!