How to format individual elements in a timeseries
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Star Strider
2023-6-13
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.
采纳的回答
Star Strider
2023-6-13
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 个评论
Les Beckham
2023-6-13
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!