Borrar filtros
Borrar filtros

random number generator to two different variables

5 visualizaciones (últimos 30 días)
cgo
cgo el 25 de Nov. de 2014
Respondida: Peter Perkins el 25 de Nov. de 2014
I want to initialize two different random numbers to be assigned to different variables. If I put in:
x_1 = rand x_2 = rand
they will get exactly the same number. How do I assign two different random numbers?
Thanksr

Respuesta aceptada

Shane
Shane el 25 de Nov. de 2014
They get different random numbers for me. Which version of Matlab are you using?
  4 comentarios
cgo
cgo el 25 de Nov. de 2014
alright. let me look into it.

Iniciar sesión para comentar.

Más respuestas (1)

Peter Perkins
Peter Perkins el 25 de Nov. de 2014
cgo, it may be that you have created a variable called "rand" in your workspace that is shadowing the rand function. The rand function does not return the same value two times in a row within the same MATLAB session.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by