Say I have data as follows:
level,age
8,10
8,11
8,11
9,10
9,11
9,11
9,11
I'm looking to form a stacked bar graph in Matlab where "level" is on the x-axis and number of occurances of that level (the frequency) is on the y-axis: so 8 would have a y-value of 3 and 9 would have a y-value of 4. Furthermore, I'm looking to have this as a stacked bar chart so level 8 would have 1 unit colored green (green is age 10) and 2 units colored red (where red is age 11) and 9 would have 1 unit colored green and 3 units colored red.
Thanks for any help!
[10 11]
in the HISTC call, instead usinguniqAge=unique(data(:,2));
. Also the legend is somewhat needed here:legend( strtrim(cellstr(num2str(uniqAge,'Age %d'))), 'Location','NorthWest')
– Rollin