clear all;

fileID = fopen('Maple_Trees_Array.txt');
B1 = textscan(fileID, '%q %q %q %q', 1);
B2 = textscan(fileID, '%q %d %d %d');
for j=1:3 xcells(j) = B1{1+j}; end
xcells
ycells = B2{1}
A = zeros(3,3);
for j=1:3 A(:,j) = B2{1+j}; end
A
%A(1,:) = B2{2}

x = [1 1 1] * A
y = A * [1; 1; 1]
z = x * [1; 1; 1]

figure(1);
bar(1:3,diag(x),'stacked');
set(gca, 'XTick', 1:3, 'XTickLabel', xcells);
xlabel({'','Species'});
ylabel({'Number of Trees',''});
title('Figure 3.1');

figure(2);
pie(x);
xlabel({'','Species'});
legend(xcells);
title('Figure 3.1');

'Overall %'
100*A/z

'Col %'
100*A*diag(x)^-1

'Row %'
100*diag(y)^-1*A


