フィルターのクリア

Transpose/combine several variables using csvwrite or writematrix

6 ビュー (過去 30 日間)
Erika Joh
Erika Joh 2019 年 4 月 26 日
コメント済み: hameed asmath 2020 年 11 月 6 日
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 件のコメント
Rik
Rik 2019 年 4 月 26 日
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.

サインインしてコメントする。

回答 (2 件)

Jeremy Hughes
Jeremy Hughes 2019 年 5 月 13 日
The function writematrix is available in R2019a.

Thomas Sievert
Thomas Sievert 2019 年 9 月 22 日
編集済み: Thomas Sievert 2019 年 9 月 22 日
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.
  1 件のコメント
hameed asmath
hameed asmath 2020 年 11 月 6 日
Hello Siebert!
I want to write analog sensor data to a CSV file. While writing I writes in row format. Iam facing the same problem. Can u able to share a sample code to solve the above question with thousands of data.
Thank you.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by