two random number columns

1 次查看(过去 30 天)
I need to genarate a series of random number from 0 to 1 using rand(5,1). against same list I need a random list of 0 and1 in second column Both must be assocated so I can use in program
e.g
0.1058 0
0.1097 0
0.0636 1
0.4046 1
0.4484 0

采纳的回答

madhan ravi
madhan ravi 2020-7-13
[rand(5, 1), randi([0, 1], 5, 1)]
  3 个评论
madhan ravi
madhan ravi 2020-7-13
a = [rand(5, 1), randi([0, 1], 5, 1)];
a(a(:,2) == 1, :) % are the ones satisfying the conditions

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Random Number Generation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by