function sum = selectsum( A, B )
%selectsum - compute the sum of the elements in B corresponding
%   to true (nonzero) values in A.  In other words, return the sum
%   over all values B(i,j) such that A(i,j) is nonzero.
% Assumes A and B have the same dimensions.

[nrows, ncols] = size(A);
sum = 0;

% YOUR CODE HERE:
% Look at each element in B, adding it to the sum
% if the corresponding element of A is nonzero

end

