How to format individual elements in a timeseries
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Stephen Forczyk
am 13 Jun. 2023
Kommentiert: Stephen Forczyk
am 13 Jun. 2023
I create a timetable as follows
% Create the Black Carbon Dry Deposition Table For Bin 001 ikind=1
BCDP001Table=table(BCDP00110(:,1),BCDP00125(:,1),BCDP00150(:,1),BCDP00175(:,1),...
BCDP00190(:,1),BCDP001100(:,1),...
'VariableNames',{'BCDP00110','BCDP00125','BCDP00150',...
'BCDP00175','BCDP00190','BCDP001100'});
BCDP001TT = table2timetable(BCDP001Table,'TimeStep',timestep,'StartTime',stime);
This produces a very serviceable timetable. I would like the ability to format the columns sa as %8.4f or %12.6e
so that when the table print out every in formatted to be read in a very clear fashion. However I have not seen a good example on how to do this. I could go back and manually edit each table element using something like sprintf but I would like to retain full accuracy for calculation and plot purposes.
2 Kommentare
Star Strider
am 13 Jun. 2023
The best way to do that would be to duplicate the table, however using string (or charactrer vector) entries. That way, you have both — a numeric table wih full precision, and a neatly-formatted table for publication. The neatly-formatted table could be created immediately from the original table, then deleted if necessary when its existence was no longer required.
Akzeptierte Antwort
Star Strider
am 13 Jun. 2023
The various table arrays inherit their formats from the existing format. The only way to force a specific format is to write them as string or character vectors. This has the disadvantage of having to re-convert them to use them, and also limits the precision to what was saved in the string or character variable.
It’s probably best to just leave them as they are if you want to retain full precision. If you then want to print them, write your own printing routine using fprintf. You can recover the variable names using <tablename>.Properties.VariableNames as a cell array, and print them separately.
.
2 Kommentare
Les Beckham
am 13 Jun. 2023
In addition to the fprintf approach, you might consider using writetimetable to write the data to an Excel spreadsheet and then use Excel to make it "pretty" for publication.
Obviously, this involves some "manual" work, but if you don't have to do it a lot, it might be worth considering
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets 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!