Randomize / Shuffle function with order (no subsequent repetition) constraint
显示 更早的评论
Hello, I am using MATLAB 2016b and I am looking to write a matlab function that randomizes / shuffles a matrix with some constraints.
Specifically, the input for this function would be a 10*1 matrix with the following content: [1;2;3;4;5;6;7;8;9;10]. Next I would like to have a variable (lets call it X) that specifies the amount of repetitions and therefore indicates the dimensions of the output matrix (see further for more clarification)
The wanted output is a X*1 matrix, with X being a multiple of 10 (e.g., 20*1, 30*1, 40*1, etc), based on the X variable that I discussed previously.
The goal is to randomize and shuffle the input matrix, and save this output to another matrix. The output matrix needs to satisfy the following constraints: - Every number from the input matrix needs to be equally present in the output matrix. So for example, if the output matrix is specified to be 20*1, every number needs to be present twice in the output matrix, and so on. - No more than two consecutive repeats from the same number are allowed in the output matrix. Thus, for example 2;2;3 is allowed, but not 2;2;2
I hope someone can and wants to help me in this quest. Thanks in advance
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!