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.
How Can I nest multiple tables?
103 views (last 30 days)
Show older comments
Andrew Murdza
on 4 Jun 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


Accepted Answer
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
Vanco MK
on 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!
More Answers (1)
Adam Danz
on 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)
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!