フィルターのクリア

how to generate numbers from 1 to 5 with respect to 1 row versus 10 columns.

5 ビュー (過去 30 日間)
jaah navi
jaah navi 2019 年 5 月 28 日
コメント済み: KALYAN ACHARJYA 2019 年 5 月 28 日
could anyone help me how to generate numbers from 1 to 5 repeatedly in a randon manner with respect to 1 row versus 10 columns.

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 5 月 28 日
編集済み: KALYAN ACHARJYA 2019 年 5 月 28 日
min=1; max=5;
result=min+(max-min)*rand(1,10)
Is this you looking for?
Or
>> randi(5,1,10)
Result:
ans =
1 4 3 4 4 5 5 2 4 1
  6 件のコメント
jaah navi
jaah navi 2019 年 5 月 28 日
I want to generate numbers 1,2,3,4,5 in a random order such that it can be repeated more than once.
for example,when i run the command randi([1,5], 1, 10) it generates the following result
5 5 1 5 4 1 2 3 5 5
when i run the same command second time it gives
1 5 5 3 5 1 3 5 4 5 (number 2 is not getting displayed)
for third time
4 1 5 5 4 4 4 2 4 1(number 3 is not getting displayed)
what I actually need is whenever i run the command all 5 numbers should be displayed.
Could you please help me on this.
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 5 月 28 日
>> data=1:5;
>> result=[data(randperm(5)),data(randperm(5))];
I tried to manually set, is it OK?

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

カテゴリ

Help Center および 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