フィルターのクリア

how to generate random integer without function??

1 回表示 (過去 30 日間)
mukim
mukim 2013 年 1 月 17 日
how can i generate random integer number on a fixed range without using any function ??
output sample: s = [12 30 33 02 17]
  2 件のコメント
the cyclist
the cyclist 2013 年 1 月 18 日
I am not sure what you mean by "without using any function". Is this a school assignment? Do you mean you need to write your own function, without relying on MATLAB's built-in generator?
Jan
Jan 2013 年 1 月 18 日
編集済み: Jan 2013 年 1 月 18 日
The "=" calls the SUBSASGN function, "[.,.,.]" calls HORZCAT. So even defining your variable "s" calls two functions. So please explain, which functions are allowed or not allowed. And ask your teacher for intelligent homework questions.
Could you please explain, what the leading zero in "02" means?

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 1 月 18 日

Walter Roberson
Walter Roberson 2013 年 1 月 18 日
Generating good random numbers is very difficult unless you use external hardware to provide the randomness. So most people who need random numbers don't do that: instead they generate pseudo-random numbers.
There are a large number of different routines to generate pseudo-random numbers. You could spend years researching the literature and developing new ones and testing them (and usually having them fail.) It is a lot easier to call the built-in MATLAB pseudo-random number generators, which have been tested and have known properties.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by