フィルターのクリア

matrix manipulation - replacing partial matrix subsets in main matrix ???

2 ビュー (過去 30 日間)
JK
JK 2019 年 5 月 17 日
回答済み: Josh 2019 年 5 月 17 日
I have two matrices : one is NxM and other is nxm (N>n, M>m).
I would like to insert nxm matrix at location starting at (x,y) by replacing existing subset.
example)
initial NxM
= 1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
nxm
= 2 2
2 2
(x,y) = (3,2)
final NxM
= 1 1 1 1 1
1 1 2 2 1
1 1 2 2 1
what is a way to do this using matlab?
thanks,

採用された回答

Josh
Josh 2019 年 5 月 17 日
You can use colon indexing:
% Create the two matrices in your example
A = ones(3, 5);
B = 2 * ones(2, 2);
% Use indexing to assign B to a sub-array of A
A(2:3, 3:4) = B;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by