Effacer les filtres
Effacer les filtres

How to format individual elements in a timeseries

2 vues (au cours des 30 derniers jours)
Stephen Forczyk
Stephen Forczyk le 13 Juin 2023
Commenté : Stephen Forczyk le 13 Juin 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 commentaires
Stephen Forczyk
Stephen Forczyk le 13 Juin 2023
That was what I was thinking-just trying to get "pretty" output for publication
Star Strider
Star Strider le 13 Juin 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.

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 13 Juin 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 commentaires
Les Beckham
Les Beckham le 13 Juin 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
Stephen Forczyk
Stephen Forczyk le 13 Juin 2023
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

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by