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

1 view (last 30 days)
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

Accepted Answer

Dyuman Joshi
Dyuman Joshi on 17 Feb 2023
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 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!