フィルターのクリア

How can we display a value of function inside for loop seperatley instead of in a form of vector?

1 回表示 (過去 30 日間)
when I excuted the code below, " select" show me the options as vector, but I want it show me these options in random way BUT WITHOUT REPEATING as follow in each iteration, for example,
2
5
3
4
1
options = [1 2 3 4 5];
for i= 1:numel(options)
select = options(randperm(i))
end
Thanks in advance

採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 2 月 17 日
A = [1 2 3 4 5];
options=randperm(numel(A));
for i= 1:numel(options)
select = options(i)
end
select = 2
select = 1
select = 3
select = 5
select = 4
  4 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 2 月 21 日
So you want run each loop once in a random order, for every iteration of main loop?
omar th
omar th 2023 年 2 月 21 日
I got the answer from another guy, thank you for your response.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by