フィルターのクリア

How to create a table for CSV-Output from an array and strings?

4 ビュー (過去 30 日間)
Aaron
Aaron 2014 年 9 月 22 日
コメント済み: Aaron 2014 年 9 月 22 日
Hello,
I have an N x N matrix of numerical values. I would like to export them as a .csv-file in such a way, that the table is already "captioned"(?) with text and be automatically input to Latex.
In other words I have this table: '' Label 1 Label 2 Label 3 X 1 2 3 Y 20 30 40
And I would like to save it as a .csv-file. I don't want to create the table manually, but I rather want to have it created automatically based on the size of the (pure numerical) input matrix.
Does anyone know how to do that?

採用された回答

Mohammad Abouali
Mohammad Abouali 2014 年 9 月 22 日
編集済み: Mohammad Abouali 2014 年 9 月 22 日
Let's say myArray is your NxN matrix and colNames is a cell array storing the labels, i.e. colNames={'Label1','Label2',...,'LabelN'}
T=Array2table(myArray,'VariableNames',colNames);
writetable(T,'filename.csv');
That would save it in CSV format.
Then you can use csvsimple in latex and use \csvreader{filename.csv}{} in your table to automatically import it in a Latex.

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by