rand command give different answer

mat.jpg
why this rand command give different result

1 Kommentar

Stephen23
Stephen23 am 9 Feb. 2020
"why this rand command give different result"
What do you expect its output to be?

Melden Sie sich an, um zu kommentieren.

Antworten (2)

James Tursa
James Tursa am 9 Feb. 2020
Bearbeitet: James Tursa am 9 Feb. 2020

1 Stimme

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 Kommentar

Iqra
Iqra am 6 Jan. 2023
beacuse rand function generates value randamly between 0 and 1 interval

Melden Sie sich an, um zu kommentieren.

Chuguang Pan
Chuguang Pan am 9 Feb. 2020

0 Stimmen

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.

Kategorien

Produkte

Version

R2019a

Gefragt:

am 9 Feb. 2020

Kommentiert:

am 6 Jan. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by