Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
How can I import a file that includes both string and numerical data?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello, All. I have a data set that has 5 rows of string data and all of the remaining data are numeric. I want to import the file while maintaining only the second row of data and all the data starting at row six and after. I really just need an output with the headers (:,second column) and another output with the data (:,6:end). Is there a way to do this simply? I have looked through other posted questions but I cannot get this to work for my purpose.
Thanks!
0 comentarios
Respuestas (2)
Swarooph
el 15 de Ag. de 2016
Hello John,
There are a few things conflicting about your question. You first say you have 5 rows of string data and then you say extract the second row and all the rows from 6 till the end. Then in your code, you are showing this with columns and not rows..
In any case, have you looked at the import tool available in MATLAB? Take a look at this documentation. You can do this interactively using the tool. If you wanted to do this using MATLAB code, you can also generate code from this tool and use it with the same file or similar files later.
1 comentario
Azzi Abdelmalek
el 15 de Ag. de 2016
fid=fopen('file.txt')
s=textscan(fid,'%s','headerlines',1,'delimiter','\n')
fclose(fid)
out=[s{:}]
out=out([1 5:end])
1 comentario
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!