How Can I nest multiple tables?
Afficher commentaires plus anciens
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
le 4 Juin 2018
Réponse acceptée
Plus de réponses (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)
Catégories
En savoir plus sur Develop Apps Using App Designer dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!