Superimposing matrices in a specific location

1 回表示 (過去 30 日間)
Allie Feinberg
Allie Feinberg 2019 年 10 月 17 日
編集済み: Matt J 2019 年 10 月 18 日
I have two matrices, one 1024x1024 and one 101x101. 95% of the matrices consists of zeros, besides the central circular parts which have values ranging between 0 and 1. When displayed, the matrices show a circle.
I want to superimpose the smaller matrix onto the larger matrix in a specific location from the origin of the larger matrix. How can I extract the values from the smaller matrix and superimpose them onto the larger matrix?
Thanks

採用された回答

Matt J
Matt J 2019 年 10 月 18 日
編集済み: Matt J 2019 年 10 月 18 日
Something like this, perhaps:
[i0,j0]=deal(700,850); %target location
[I,J,S]=find(smallMatrix);
result = largeMatrix + accumarray([I-51+i0,J-51+j0], S ,[1024,1024]);
  2 件のコメント
Allie Feinberg
Allie Feinberg 2019 年 10 月 18 日
Thanks so much, this worked!
Matt J
Matt J 2019 年 10 月 18 日
編集済み: Matt J 2019 年 10 月 18 日
Glad to hear it, but please Accept-click the answer to indicate this!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by