two random number columns

1 Ansicht (letzte 30 Tage)
abdul rehman
abdul rehman am 13 Jul. 2020
Kommentiert: abdul rehman am 13 Jul. 2020
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

Akzeptierte Antwort

madhan ravi
madhan ravi am 13 Jul. 2020
[rand(5, 1), randi([0, 1], 5, 1)]
  3 Kommentare
madhan ravi
madhan ravi am 13 Jul. 2020
a = [rand(5, 1), randi([0, 1], 5, 1)];
a(a(:,2) == 1, :) % are the ones satisfying the conditions
abdul rehman
abdul rehman am 13 Jul. 2020
thank you so much

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Random Number Generation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by