how to distribute a matrix elements randomly matlab

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 件のコメント

Image Analyst
Image Analyst 2016 年 10 月 9 日
編集済み: Image Analyst 2016 年 10 月 9 日
Seems like an unusual, quirky thing to want to do. Is this homework? Hint: try unique() and randi(). Note, though it's solvable for that specific m and n, it may not be possible to solve for an n of that size (3x10) and any arbitrary m.
wee
wee 2016 年 10 月 9 日
編集済み: wee 2016 年 10 月 9 日
yes, this is one of thesis code :). i've tried unique and randi, but still don't know to distribute on another matrix would you like give me a solution?thank you before..
Massimo Zanetti
Massimo Zanetti 2016 年 10 月 9 日
So Image Analyst.. please do his thesis work! Come on!
Marc Jakobi
Marc Jakobi 2016 年 10 月 9 日
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.
wee
wee 2016 年 10 月 9 日
m = [ 1 1 3 3 3 4 4 6 6 7 7 7]; n = zeros(3,10); x = randsample( numel(n), numel(m) ); n(id) = x; i tried this

サインインしてコメントする。

 採用された回答

Massimo Zanetti
Massimo Zanetti 2016 年 10 月 9 日
編集済み: Massimo Zanetti 2016 年 10 月 9 日

3 投票

Joking aside, try to subdivide the whole thing into sub-tasks. I try to give you an example:
  1. Identify in vector m the k starting indeces of all repeated sequences of numbers.
  2. Get k random indeces that fit the shape of matrix n.
  3. Put the sequences in the matrix (after simple checking of their length and the row size)
Working on this maight help, I think.

1 件のコメント

wee
wee 2016 年 10 月 9 日
thank you so much, I'll try ...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

wee
2016 年 10 月 9 日

コメント済み:

wee
2016 年 10 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by