MATLAB Answers

Variable out_vec must be of size [1 3]. It is currently of size [1 20]. Check where the variable is assigned a value.

4 views (last 30 days)
Raizel Lampert
Raizel Lampert on 27 Jul 2021
Commented: KSSV on 27 Jul 2021
How can I reduce [1 20] size to a [1 3] size, without getting in the problem of needing only the number 1 10 and 20 in a vector row?

Answers (1)

KSSV
KSSV on 27 Jul 2021
x = 1:20 ;
idx = sort(randperm(length(x),3)) ; % select randomly
x(idx)
ans = 1×3
3 6 8

Community Treasure Hunt

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

Start Hunting!