I am using the code below to allow me to select a single "random" element from an array with each element having its own weighting.
p=[10 20 30 40];
Suppose my requirements now change, and only elements 3 and 4 can be selected from A. Without having to redo the percentages (i.e. changing p array), how can I modify the inputs to the histc function to achieve this?