Combining y columns of several x,y matrices into one matrix
조회 수: 5 (최근 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에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!