Given M and lamda by the user, i am trying to write matlab code that produces a vector of increasing size whose entries are exponentially distributed random variables (mean 1/lambda) until the sum of the vector exceeds M..

any ideas how to do this?? I have been trying with while loops but cant quite do it...