MATLAB Answers

0

Transpose/combine several variables using csvwrite or writematrix

Erika Joh 님이 질문을 제출함. 26 Apr 2019
최근 활동 Thomas Sievert 님이 편집함. 22 Sep 2019
I have several variables that are in row form. I would like to write a script that will transpose these variables into column form and then combine write them into one csv file with each variable in a separate row. I have been able to export them individually in row form using csvwrite, but I'm not sure if I'm able to manipulate and combine variables with this or if I need to use writematrix instead. However, when I try to use this, it gives me the error: Undefined function or variable 'writematrix'.

  댓글 수: 1

If you want each variable as a row, why would you transpose them in the first place? Also, please show the code you've tried, and give an example of input and intended output.

로그인 to comment.

답변 수: 2

Answer by Jeremy Hughes on 13 May 2019

The function writematrix is available in R2019a.

  댓글 수: 0

로그인 to comment.


Answer by Thomas Sievert on 22 Sep 2019
Edited by Thomas Sievert on 22 Sep 2019

Hi,
If you have a vector or matrix X, you can use the : symbol to flatten it into a column vector. Supposing you have several row/column vectors of equal length, you can put them all as columns in a matrix like this:
[vec1(:), vec2(:), vec3(:)]
Alternatively, you can structure your data as a table, then use the function writetable.

  댓글 수: 0

로그인 to comment.



Translated by