Combining y columns of several x,y matrices into one matrix
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Michel Nieuwoudt
el 24 de Sept. de 2018
Respondida: Michel Nieuwoudt
el 25 de Sept. de 2018
OK, I've edited my request with more detail: I have ten (1554x2) .csv files of x,y data (I've attached eight here, for some reason couldn't load the other two!). I want to combine all the y columns of these into one matrix, with the names of each column as the first row. How do I do this please? It's OK if I don't have the names of the files included in the matrix, as long as the order in which they are added to the matrix is the same as the list of files? Thank you!
0 comentarios
Respuesta aceptada
Stephen23
el 24 de Sept. de 2018
Editada: Stephen23
el 24 de Sept. de 2018
"How do I do this please?"
By following the guidelines in the MATLAB documentation:
And concatenating the data vertically after the loop:
M = vertcat(C{:})
Numeric arrays do not store character data, so you cannot add headers as the first row of a numeric matrix. You could use a table, which has headers, but makes accessing the data slightly more complex. Your choice.
Note that you will have to make some decisions about how to read the files, depending on some information which you have not told us, e.g. how the files are named, what sequence you want the files imported in, what file format they use (including any delimiter, etc (I know you wrote CSV, but we regularly get people calling tab-delimited or semi-colon-delimited files "CSV" files)). Basically without an explanation of the filenames and their required order and a sample file or two, there is not much more that we can do for you. You can upload sample files by editing your question and clicking the paperclip button.
4 comentarios
Stephen23
el 25 de Sept. de 2018
@Michel Nieuwoudt: I hope that it helped. Remember to accept my answer!
Más respuestas (1)
Ver también
Categorías
Más información sobre Text Files 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!