How Can I nest multiple tables?

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 Comment

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.

Sign in to comment.

 Accepted Answer

Walter Roberson
Walter Roberson on 4 Jun 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 Comments

Thanks Walter!
I'll try looking at uitables. I'll post another question if I have trouble using those.
Sorry for the late reply.
Thanks again, Andrew Murdza
Also, is it possible to nest uitables and with the contents inside showing?
Thanks, Andrew Murdza
It is not possible to nest uitable()
To get more complicated display tables you will probably need to go in at the Java level. I recommend reading http://undocumentedmatlab.com for more information about uitable and java.
Thanks Walter!
Andrew Murdza
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!

Sign in to comment.

More Answers (1)

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

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!