how to distribute a matrix elements randomly matlab
2 views (last 30 days)
Show older comments
hi everyone how to make a matrix randomly distributed to another matrix n,
m = [ 1 1 3 3 3 4 4 6 6 7 7 7];
n = zeros(3,10);
the same value must in the sequence, ex : 4 4 4, 7 7 7.result reqiured can be something like {or other combinations):
distributed_matrix =
0 1 1 0 7 7 7 0 0 0
0 0 3 3 3 4 4 0 0 0
6 6 6 0 0 0 0 0 0 0
5 Comments
Marc Jakobi
on 9 Oct 2016
You should post what you have attempted so far, if it is homework; even if the results are wrong - to show that you at least tried.
Accepted Answer
Massimo Zanetti
on 9 Oct 2016
Edited: Massimo Zanetti
on 9 Oct 2016
Joking aside, try to subdivide the whole thing into sub-tasks. I try to give you an example:
- Identify in vector m the k starting indeces of all repeated sequences of numbers.
- Get k random indeces that fit the shape of matrix n.
- Put the sequences in the matrix (after simple checking of their length and the row size)
Working on this maight help, I think.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!