Tabluate data using common terms in varaible names
Show older comments
Is there a way to place the data below in a table with column names MLD, MOD, WG and OUT and rows by ab, ac, ad, ae, using the common terms in the varaiable names?
Table
MLD MOD WG OUT
ab
ac
ad
ae
ab_MLD = 2
ac_MLD = 5
ad_MLD = 2
ae_MLD = 5
ab_MOD = 6
ac_MOD = 3
ad_MOD = 9
ae_MOD = 4
ab_WG = 14
ac_WG = 3
ad_WG = 4
ae_WG = 1
ab_OUT = 2
ac_OUT = 6
ad_OUT = 3
ae_OUT = 5
Accepted Answer
More Answers (1)
You can specify the rownames property of the table.
a = array2table(zeros(4,4),'RowNames',{'ab' 'ac' 'ad' 'ae'},'VariableNames',{'MLD' 'MOD' 'WG' 'OUT'});
a{'ab','MLD'} = 2
a{:,'MLD'} = [2;5;2;5]
a{:,:} = [2 6 14 2; 5 3 3 6; 2 9 4 3; 5 4 1 5]
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!