Borrar filtros
Borrar filtros

Export of table results in PDF

12 visualizaciones (últimos 30 días)
FRANCESCOMARIA
FRANCESCOMARIA el 16 de Oct. de 2023
Comentada: Chunru el 18 de Oct. de 2023
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?

Respuestas (1)

Chunru
Chunru el 17 de Oct. de 2023
Editada: Chunru el 17 de Oct. de 2023
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 comentarios
FRANCESCOMARIA
FRANCESCOMARIA el 17 de Oct. de 2023
It works, but is print just a part of the table I need. Like the file I Upload.
Chunru
Chunru el 18 de Oct. de 2023
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)

Iniciar sesión para comentar.

Categorías

Más información sobre Vector Autoregression Models en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by