Start with the 4 files on cpteach in the directory ~pryke/astr401/exam/qu1. (Be sure to use the slightly modified 050517_calsrc1_edit2.mat version of the input data.)
x=0:0.01:2; y=0.5*exp(0.7*x)+gauss([3,1,0.05],x); vals=hrndm(x,y,10000); hfill(vals,100,0,2);
and see a noisy histogram of a gaussian peak sitting on an exponential background. [Hint: You need only the functions cumsum, rand and interp1 and can do it cleanly with 3 lines of code and no loops.]
Remember to keep the code simple and clean!