Generating Pseudo Random Numbers in MATLAB

I wrote the code found in this post in the Student Version of MATLAB R2009a ( on Windows Vista SP2.

This function will return a vector of size i containing randomly generated numbers uniformly distributed between 0 and 1. It’s not perfect, but it got the job done. I’ll get around to explaining it more beyond the meager comments another time.

Generating Random Numbers
Linear congruential generator

4 thoughts on “Generating Pseudo Random Numbers in MATLAB

  1. Hi!

    My name is Anna and I want to thank you for posting this code, I need to modify the code for a project digital image processing, where I need a pseudo random noise sequence and researching I came to this was reduced to generate a sequence of random numbers . The particularity of the noise I create is that I should only have values between -1, 0 and 1 and then there’s my mission. Thank you very much again!

    Sorry for my bad English 😛

  2. Hi Anna. What type of distribution are you trying to generate these numbers under? Uniform, random, etc. See: for an easy way to generate matrices of uniformly distributed numbers and for normally distributed numbers.

    My method of generating random numbers is a bit cumbersome, but seemed to work for my application. It may not work for yours. Good luck!

Leave a Reply

Your email address will not be published. Required fields are marked *