Format t-stat in square brackets

5 vues (au cours des 30 derniers jours)
Parveshsingh Seeballack
Parveshsingh Seeballack le 16 Sep 2021
Hi All
I am trying to format the below code such that the t-stats are in square brackets.
if freq ==1 % for monthly sample
disp(' Table 5, Appendix Format')
disp(' SPX Pseudo Spreads')
lbs = {'HOVS','t-stat','Pseudo Spread','t-stat','Term Spread','t-stat','Real FFR','t-stat','VIX','t-stat','R2'};
disp('')
disp(' Panel A: Payroll Growth')
disp('')
for kk=1:11
fprintf('%14s %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f \n',...
char(lbs(kk)),TABLE_Final_Appendix(kk,:,1))
end
Also, how do I export the results in excel format.
Thank you four your help.
Regards
Parvesh

Réponses (1)

Star Strider
Star Strider le 16 Sep 2021
With respect to the square brackets —
x = randn(1,5);
fprintf('[%8.4f]\n',x)
[ 0.2151] [ 0.7526] [ 0.0942] [ -0.9181] [ -0.0554]
Also, how do I export the results in excel format.
It might be easiest to save all that to a cell array, then use the writecell function.
Another option is to create it as a table, and use writetable.
However, it might be best to write it line-by-line to a text file, and use the approopriate combination of 'HeaderLines' and other options with respect to reading it (as a table or matrix). Writing it and reading it later are going to be something of a challenge, regardless.
.

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by