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 个评论
Stephen Forczyk
Stephen Forczyk 2023-6-13
That was what I was thinking-just trying to get "pretty" output for publication
Star Strider
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
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
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
Stephen Forczyk
Stephen Forczyk 2023-6-13
Lee-thanks for your response. I considered doing just that but I generally avoid "touch" labor at all costs. I do frequently use Matlab lab and Excel together as many Gov't users don't have access to Matlab. For them I crate a PDF using the Matlab Report Generator or one of the many packages for reading and writing data from Excel. Thanks for your comments

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by