title: Sum over all subsets in matlab
body: <p>Given a number 'c' and a list of numbers 'numbers', I am trying to generate all the sums I can have of c and any subset in numbers.
  eg. (1,[2,4,8]), I should generate (note that we should always have c in a sum)
  [1,3,5,9,7,11,13,15]</p>
  
  <p>I wrote the following code, but not all sums appear. What is wrong?</p>
  
  <pre><code>function result = allsums(c, numbers)
      if isempty(numbers)
          result = [];
      else
          [nr n_numbers] = size(numbers);
          for i = 1:n_numbers
              result = cat(2, c+numbers(i), allsums(c, cat(2,numbers(1:i-1),numbers(i+1:end))));
          end
      end
  
  result = cat(2, result, c+sum(numbers,2));
  end
  </code></pre>