If I want to arbitraraly choose any number $(1\sim9)$ of arbitrarily elements within $(1\sim9)$:
Ex:
1. $n = 3$ (randomly) $\rightarrow$ choose $"1,4,9"$ (randomly & no repeat)
2. $n = 2$ (randomly) $\rightarrow$ choose $"9,10"$ (randomly & no repeat)
How to use Matlab to implement it?
- I know
randsample; however,randsamplecan only choose one value randomly. - Use
for loop. The bad news is this method will repeat the choice.
Any good way?