How to use randperm command with same starting and ending number each time to generate random numbers?
1 view (last 30 days)
Show older comments
N=7;
Startingnumber= any number from 1 to N
EndingNumber=any number from 1 to N
I need to create R=randperm(N-2) and the logic is that starting and ending number must not be included. So, I can obtain;
X=[Startingnumber R Endingnumber]
Example:
N=7;
Startingnumber= 3;
EndingNumber=6;
R=2 1 5 7 4 (randomly generated)
output;
X=[3 2 1 5 7 4 6]
OR, if there is any other command?
______________________________________________________________________________________________________
Thankyou!
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Random Number Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!