% program LoadIO.m
% This loads in the Make and Use matricies from the FIRST SHEET of xls
% files
% modified Aug 29 2008.  pb.

% First, set the proper directory, if needed
% cd 'C:\Documents and Settings\All Users\Desktop\GSR Project Master Folder\BEA IO Data'
%%
clear all;
M = xlsread('2002MakeExpansion.xlsx');

%%
U = xlsread('2002UseExpansion.xlsx');

nm = size(M);
nu = size (U);

% Now get rid of row and column headers
%M = M(2:nm(1), 2:nm(2));
%U = U(2:nm(1), 2:nm(2));






%calcIO.m   This calcs the IO matrix
%Run this after running loadIO.m

s = size(M,1);  %about 101, the number of rows and columns of M
% sum(M) returns a row vector of the sums of each column
%  it is the total amount of a commodity made (total taken over industries)
ratio = repmat(sum(M),s,1);

%ratio is s=101 rows deep and each row being sum(M) which is 101 wide
MS = M ./ ratio;  %element by element division
%%
IO = MS * U;
%%
% Now write to a Excel file
xlswrite('AggregateIOtable.xls', IO);
   
   
   
   
   
