How to export 1 column of data with variable names on separate lines

2 ビュー (過去 30 日間)
Dean Morris
Dean Morris 2022 年 3 月 16 日
コメント済み: Stephen23 2022 年 3 月 16 日
My main problem, is that I am using the 'table' and 'writetable' commands, however I would like the exported text file to not all be on one line but me more along the lines of whats shown below
Odd_term1 value
Odd_term2 value
etc...
whereas at the moment it looks like this
Odd_term1,Oddterm2,
value,value
etc....
below is the lines of code I am using to try and achieve this, thanks in advance for any help.
T = table(data.PresiOddterms, 'VariableNames', {'Odd_terms'})
writetable(T, 'resistor_data')

採用された回答

Mathieu NOE
Mathieu NOE 2022 年 3 月 16 日
hello
this demo to flip a (vertical) 5 (variables) x 3 (values) table to hor direction
now the saved data (in txt file) is like :
Var1 0.644318130193692 0.378609382660268 0.811580458282477
Var2 0.532825588799455 0.350727103576883 0.939001561999887
Var3 0.875942811492984 0.550156342898422 0.622475086001227
Var4 0.587044704531417 0.207742292733028 0.301246330279491
Var5 0.470923348517591 0.230488160211558 0.844308792695389
T = array2table(rand(3,5));
VariableNames = (T.Properties.VariableNames)';
data = (table2cell(T))';
% flip directions of table to output txt file
Out = [VariableNames data];
writecell(Out,'savefile.txt',"Delimiter","tab");
  2 件のコメント
Dean Morris
Dean Morris 2022 年 3 月 16 日
Great thank you so much
Mathieu NOE
Mathieu NOE 2022 年 3 月 16 日
thanks !
would you mind accepting my answer ?

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by