Export of table results in PDF

33 次查看(过去 30 天)
FRANCESCOMARIA
FRANCESCOMARIA 2023-10-16
评论: Chunru 2023-10-18
close all
clear all
clc
[xlsdata, xlstext] = xlsread('SW3.xlsx','Foglio1');
t = datetime(xlstext(2:end,1),"Format","dd/MM/uu");
DataTimeTable = table(t,xlsdata(1:end,1),xlsdata(1:end,2),xlsdata(1:end,3),xlsdata(1:end,4),xlsdata(1:end,5),xlsdata(1:end,6),xlsdata(1:end,7));
DataTimeTable.Properties.VariableNames = xlstext(1,1:8);
INFO = xlsdata(1:end,1);
mth3USArate = price2ret(DataTimeTable.USA3mth);
mth3USArate = [0; mth3USArate];
CPIUS = xlsdata(1:end,3);
UnempUS = price2ret(DataTimeTable.unempUS);
UnempUS = [0; UnempUS];
USDto1eu = price2ret(DataTimeTable.USDto1euro);
USDto1eu = [0; USDto1eu];
gfc = xlsdata(1:end,6);
UnempEU = price2ret(DataTimeTable.unempUE);
UnempEU = [0; UnempEU];
UnempEU(isinf(UnempEU)|isnan(UnempEU)) = 0
tbl = table(INFO,mth3USArate,CPIUS,UnempUS,USDto1eu,gfc,UnempEU);
tbl = rmmissing(tbl);
T = size(tbl,1); % Total sample size
numseries = 7;
numlags = (1:4)';
nummdls = numel(numlags);
% Partition time base.
maxp = max(numlags); % Maximum number of required presample responses
idxpre = 1:maxp;
idxest = (maxp + 1):T;
% Preallocation
EstMdl(nummdls) = varm(numseries,0);
aic = zeros(nummdls,1);
% Fit VAR models to data.
Y0 = tbl{idxpre,:}; % Presample
Y = tbl{idxest,:}; % Estimation sample
for j = 1:numel(numlags)
Mdl = varm(numseries,numlags(j));
Mdl.SeriesNames = tbl.Properties.VariableNames;
EstMdl(j) = estimate(Mdl,Y,'Y0',Y0);
results = summarize(EstMdl(j));
aic(j) = results.AIC;
end
[~,bestidx] = min(aic);
p = numlags(bestidx)
BestMdl = EstMdl(bestidx);
h = gctest(BestMdl);
CONSIDERING THE RESULTS OF THIS CODE, HOW CAN I PRINT IT AS A PDF TABLE AND EXPORT FROM MATLAB?

回答(1 个)

Chunru
Chunru 2023-10-17
编辑:Chunru 2023-10-17
You can use livescript. Then you can hide the code and export to pdf.
For example
t=array2table(rand(3,2));
disp(t)
Var1 Var2 _______ _______ 0.98776 0.24769 0.5965 0.27823 0.96934 0.47891
Or you can export a formatted table with grid as follows (the display below is not the same from livescript):
t=array2table(rand(3,2))
t = 3×2 table
Var1 Var2 ________ _______ 0.044266 0.52897 0.48844 0.65341 0.43366 0.56366
  7 个评论
FRANCESCOMARIA
FRANCESCOMARIA 2023-10-17
It works, but is print just a part of the table I need. Like the file I Upload.
Chunru
Chunru 2023-10-18
The reson may be that your table is too big to fit into the page width of pdf.
Try the following
export->export to pdf->Show more -->Paper size --> A2/landscape (or custom for larger widths)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Vector Autoregression Models 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by