random number generator to two different variables

5 次查看(过去 30 天)
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

采纳的回答

Shane
Shane 2014-11-25
They get different random numbers for me. Which version of Matlab are you using?
  4 个评论

请先登录,再进行评论。

更多回答(1 个)

Peter Perkins
Peter Perkins 2014-11-25
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.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by