How Can I nest multiple tables?

67 vues (au cours des 30 derniers jours)
Andrew Murdza
Andrew Murdza le 4 Juin 2018
I want to construct this table in matlab. I tried to make this table by partitioning it into 25 smaller tables (surrounded in bold) which I tried to nest in one large table. close all; clear all;
stocknames=["S&P500","Oracle","Symantec","Open Text","Trend Micro","Cloudera","SNAP","Maximus","CSG International","Intel","PTC","ACI World Wide","Ambdocs Limited","Microsoft Corporation"];
stocks=["^SP500TR","ORCL","SYMC","OTEX","TMICY","CLDR","SNAP","MMS","CSGS","INTC","PTC","ACIW","DOX","MSFT"];
modelnames=["Prototype Model","Protoype w/ Moving Avgs","Index Model","Index w/ Moving Averages"];
totaldays=365;
numberofdaysinmovingaverage=10;
daysintofuture=50;
%Generates Data from Models
[pmar(:,1),mmar(1),stdmar(1),dayspred(:,1),meanpred(1),stdpred(1)]=PrototypeModelData(daysintofuture,totaldays,stocks);
[pmar(:,2),mmar(2),stdmar(2),dayspred(:,2),meanpred(2),stdpred(2)]=PrototypeModelMovingAvgsData(daysintofuture,totaldays,stocks,numberofdaysinmovingaverage);
[pmar(:,3),mmar(3),stdmar(3),dayspred(:,3),meanpred(3),stdpred(3)]=PrototypeModelAndIndexData(daysintofuture,totaldays,stocks);
[pmar(:,4),mmar(4),stdmar(4),dayspred(:,4),meanpred(4),stdpred(4)]=PrototypeModelAndIndexMovingAvgData(daysintofuture,totaldays,stocks,numberofdaysinmovingaverage);
%creates subtables
tables{1,1}=array2table("Stock");
tables{2,1}=cell2table({'Name','Symbol'});
tables{3,1}=array2table([stocknames',stocks']);
tables{4,1}=array2table("Average");
tables{5,1}=array2table("Standard Deviation");
for cnt=1:size(modelnames,2)
tables{1,cnt+1}=array2table(modelnames);
tables{2,cnt+1}=cell2table({'Days Predicted','%ME'});
tables{3,cnt+1}=array2table([dayspred(:,cnt),pmar(:,cnt)]);
tables{4,cnt+1}=array2table([meanpred(cnt),mmar(cnt)]);
tables{5,cnt+1}=array2table([stdpred(cnt),stdmar]);
end
table=cell2table(tables)
I got this result: I want the numbers and strings to show instead of [14x1 table] and I want to get rid of tables1, ... tables5 and the five black bars below those words. Lastly, I want to make grid lines for the table, but I think I can do that with the border property of the 25 tables.
Thanks so much!
Andrew Murdza
  1 commentaire
Andrew Murdza
Andrew Murdza le 4 Juin 2018
The reason it is 14x2 and not 10x2 in the output is because I wrote the code for 14 stocks but I eventually use only 10 stocks.

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 4 Juin 2018
The only way you could get the table contents displayed instead of the [ size table ] summary would be to hack the code that impliments table display.
If I recall correctly, I once posted which deep internal function would have to be changed, but finding that among my other posts might take some digging.
Getting gridlines or getting rid of the header would require similar hacks to the implementation.
There is no table borders property that comes to mind. I think you might be thinking of uitable rather than table objects.
You appear to be trying to use table objects for presentation purposes, which they were never designed for: they are designed for computation and memory saving.
uitable were designed for graphics presentation... Though could certainly have been improved for that purpose.
  5 commentaires
Andrew Murdza
Andrew Murdza le 4 Juin 2018
Thanks Walter!
Andrew Murdza
Vanco MK
Vanco MK le 18 Jan 2022
Dear Andrew,
I found your question related with your Bachelor degree research,and I would like to ask if its possible to have the data for the matlab codes that are attached at the end of your paper, becuae the yahoo finance is down. Thanks!

Connectez-vous pour commenter.

Plus de réponses (1)

Adam Danz
Adam Danz le 16 Jan 2023
Starting in MATLAB R2018b, tables can be nested as subtables by adding a table as a table variable.
Lancaster = table(rand(5,1),rand(5,1),'VariableNames',{'A','B'});
Cincinnati = table(rand(5,1),rand(5,1),'VariableNames',{'A','B'});
Sofia = table(rand(5,1),rand(5,1),'VariableNames',{'A','B'});
Rochester = table(rand(5,1),rand(5,1),'VariableNames',{'A','B'});
T = table(Lancaster, Cincinnati, Sofia, Rochester)
T = 5×4 table
Lancaster Cincinnati Sofia Rochester A B A B A B A B __________________ ___________________ ___________________ __________________ 0.37696 0.58663 0.90082 0.6907 0.76707 0.37094 0.99084 0.95786 0.61856 0.72261 0.79677 0.35421 0.98391 0.12175 0.94089 0.74575 0.35055 0.18615 0.77122 0.99533 0.96213 0.30616 0.42189 0.40929 0.14592 0.76962 0.016928 0.90054 0.78713 0.059376 0.30692 0.65894 0.4947 0.90196 0.50476 0.58607 0.64025 0.60889 0.72456 0.8412

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by