Maintaining a number generated through randomization

1 回表示 (過去 30 日間)
Danish Iqhwan Rohaizad
Danish Iqhwan Rohaizad 2022 年 5 月 19 日
回答済み: Torsten 2022 年 5 月 19 日
Greetings, I would like to ask if there is a way to code so that a random number of two different variables generated would stay constant at a given point
Let's say if a = rand(1,5) and b = rand(1,5) for the variable P01 = [124638.717 126432.080 128225.442 130018.805 131812.168], is there a way to code so that
At P01 = 124638.717 would have a value something like a = 0.123 and b = 0.211 but through randomized and these values are maintain everytime when the codes runs ?
Additionally, I would like the same thing to occur on the rest of the values of P01, the values of a and b generated would be constant everytime when the code runs

回答 (1 件)

Torsten
Torsten 2022 年 5 月 19 日
Try
rng('default')
as the first line of your code.

Community Treasure Hunt

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

Start Hunting!

Translated by