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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops 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