Create a matrix through replacement, from another matrix

1 回表示 (過去 30 日間)
stelios loizidis
stelios loizidis 2020 年 6 月 11 日
コメント済み: stelios loizidis 2020 年 6 月 11 日
Hello. I have a matrix A (5X5) and I want to create a matrix B (of the same size as A) and its values come from matrix A. Also, it is allowed to reapeat. That, is the data can be selected, never, once or more times from matrix A and replaced in matrix B. For example:
A=[1 2 3 4 5
6 7 13 11 8
22 34 45 67 78
99 41 80 91 32
60 69 64 71 76]
B=[69 2 6 11 67
1 22 34 8 60
69 2 2 80 91
64 71 76 69 99
7 13 11 60 71]
Your help is important!!!
  2 件のコメント
madhan ravi
madhan ravi 2020 年 6 月 11 日
What’s the pattern?
stelios loizidis
stelios loizidis 2020 年 6 月 11 日
There is no pattern. Just randomly select numbers from matrix A and replace them to matrix B.

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

採用された回答

madhan ravi
madhan ravi 2020 年 6 月 11 日
編集済み: madhan ravi 2020 年 6 月 11 日
B = A(randi(numel(A),size(A)))
  3 件のコメント
madhan ravi
madhan ravi 2020 年 6 月 11 日
It works for both the case.
stelios loizidis
stelios loizidis 2020 年 6 月 11 日
I tried it. It works. Thank for the help!!!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by