Home > Matlab > How to genereate random integer numbers ?

How to genereate random integer numbers ?

Last night I need to solve this question. This stuff is very easy to do under JAVA based languages but not so easy under Matlab. I thought for while and then I realized that this is very simple. To generate random number under Matlab you are commonly using function rand(NUMBER). Rand generate array that’s the case. I thought for while and here is the simple solution.

%define size of Ineger number you need
size = 100
iNum = round(rand(1)*100);
% You get number example. iNum = 23
Advertisements
Categories: Matlab
  1. September 6, 2009 at 8:19 pm

    Tnx for nice blog. It’s really interesting, I’m continue to read your blog and waitning for your next posts =).

  2. September 9, 2009 at 2:21 pm

    I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

    Susan

    http://dclottery.info

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: