How do I fit smaller matrix into a larger matrix

7 ビュー (過去 30 日間)
Abdul Rahim Mohammad
Abdul Rahim Mohammad 2019 年 4 月 30 日
編集済み: Abdul Rahim Mohammad 2019 年 4 月 30 日
Hello everyone,
I have A = matrix of 23x23, and I must reshape this matrix to the same size of an matrix I of 256x256. I want to form a 256x256 matrix that take all values in the 23x23 matrix and rest of the elements are zeros. How would I go about doing that?
I do not want to use pad, I simply want to create a zeros matrix with size of I and replace the values in zeros matrix with that of A.
Thank you for your time.

採用された回答

madhan ravi
madhan ravi 2019 年 4 月 30 日
[m,n]=size(A);
I = zeros(256);
I(1:m,1:n) = A
  1 件のコメント
Abdul Rahim Mohammad
Abdul Rahim Mohammad 2019 年 4 月 30 日
編集済み: Abdul Rahim Mohammad 2019 年 4 月 30 日
Thank you Madhan, could you generalize it a bit more? Lets say I didnt know the size of A and size of I beforehand? How would I perform the same operations?
Edit: nvm, I figured it out.
Thanks Madhan!

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

その他の回答 (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