Borrar filtros
Borrar filtros

generate same random matrix in another computer..

2 visualizaciones (últimos 30 días)
Abhishek sadasivan
Abhishek sadasivan el 12 de Sept. de 2014
Comentada: Abhishek sadasivan el 13 de Sept. de 2014
Hai ..I have a doubt ,whether it is possible to get same random matrix in another computer where same matlab software is installed . consider A= rand(2,3) when I entered this in my computer in home .I got A= 0.8147 0.1270 0.6324 0.9058 0.9134 0.0975 I would like to send A matrix to my computer in my office.Instead of sending the full matrix A ,I would like to generate the same random matrix in my office ..whether it is possible ???..

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 12 de Sept. de 2014
Use rng
rng(10)
rand(4)

Más respuestas (1)

Guillaume
Guillaume el 12 de Sept. de 2014
random number generators are not really random, they just generate a sequence of numbers that appear random using formulas based on an internal state. If you set the same internal state the formula give you the same number.
Normally, you do not want the number generation to be reproducible, so you initialise the state with something unpredictable, like the current time but you can also initialise it with a fixed state. You use rng to initialise the state, Thus start your program on both computers with
rng(any_positive_number_of_your_choosing)

Community Treasure Hunt

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

Start Hunting!

Translated by