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 日

0 投票

[rand(5, 1), randi([0, 1], 5, 1)]

3 件のコメント

abdul rehman
abdul rehman 2020 年 7 月 13 日
sir, can you tell me just one more thing, how can i select from above using condition , only those which have 1 againt them. thanks
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
abdul rehman
abdul rehman 2020 年 7 月 13 日
thank you so much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by