How to export 1 column of data with variable names on separate lines
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dean Morris
am 16 Mär. 2022
Kommentiert: Stephen23
am 16 Mär. 2022
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')
Akzeptierte Antwort
Mathieu NOE
am 16 Mär. 2022
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Text Files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!