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

2 次查看(过去 30 天)
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");

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by