Combining y columns of several x,y matrices into one matrix
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Stephen23
2018-9-24
编辑:Stephen23
2018-9-24
"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 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!