rand command give different answer

1 回表示 (過去 30 日間)
Abdullah Haris
Abdullah Haris 2020 年 2 月 9 日
コメント済み: Iqra 2023 年 1 月 6 日
mat.jpg
why this rand command give different result
  1 件のコメント
Stephen23
Stephen23 2020 年 2 月 9 日
"why this rand command give different result"
What do you expect its output to be?

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

回答 (2 件)

James Tursa
James Tursa 2020 年 2 月 9 日
編集済み: James Tursa 2020 年 2 月 9 日
rand( ) is a random number generator ... it is supposed to give a different result.
doc rand
If you want to start over with the same stream of numbers you will need to re-seed it.
  1 件のコメント
Iqra
Iqra 2023 年 1 月 6 日
beacuse rand function generates value randamly between 0 and 1 interval

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


Chuguang Pan
Chuguang Pan 2020 年 2 月 9 日
All the random number functions, rand, randn, randi, and randperm, draw values from a shared random number generator. Every time you start MATLAB, the generator resets itself to the same state.
The rand function draw values from a RandStream.

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by