Search Program on this blog

Friday 6 November 2015

Write a function called randomness that takes three input arguments: limit, n, and m, in that order. The function returns an n-­‐by-­‐m matrix of uniformly distributed random integers between 1 and limit inclusive. You are not allowed to use randi, but you can use rand. You will also find the built-­‐in function floor useful for obtaining integers. To make sure that your result is indeed uniformly distributed, test the output of the function by using the built-­‐in function hist, which plots a histogram.

function M = randomness(limit,n,m)
M = floor(1+ rand(n,m)*limit);
hist(M);

No comments:

Post a Comment