Weighted dice with n faces
If you're trying to speed up the code, I would do a couple of things.  You have some redundant processing, such as this:

cumulative_weight = zeros(1, num_weight + 1);
for j=1:num_weight
   cumulative_weight(j+1) = sum(weight(1:j));
end


which is performed 1000 times inside weighted_dice, but you really only need to do it once.  I would also get rid of the face labels altogether, because you don't care what the 6 faces are called, you just care about the distribution of results.  Finally, you can use the MATLAB builtin histc to generate the results in a vectorized fashion.

function face_index = new_weighted_dice(cumulative_weight)
    % cumulative_weight = cumulative distribution function to draw against
    % output: face_index is the discrete face after tossing a virtual dice with given
    % faces and weight.


% pick a random value unif. distrib. betw. 0 and the sum of the weights.
rand_w = unifrnd(0, cumulative_weight(end));
% check in which interval of the cumulative_weight is this element 
for j=1:num_weight
   if rand_w &gt;= cumulative_weight(j) &amp;&amp; rand_w &lt; cumulative_weight(j+1)
       break
   end
end

% assign the interval found to the value of the face
face_index = j;
end


%%%--------------main script

cumulative_weight = zeros(1, num_weight + 1);
for j=1:num_weight
   cumulative_weight(j+1) = sum(weight(1:j));
end
val = zeros(1,1000);
for i=1:1000
    val(i) = new_weighted_dice(cumulative_weight)
end

beans = histc(val, cumulative_weight);


Short, clean, fast.