How to change value of sub-rectangle in large array

1 回表示 (過去 30 日間)
Alex
Alex 2014 年 2 月 19 日
回答済み: Walter Roberson 2014 年 2 月 19 日
I have a 1200x1200 array of zeros and I want most of them to be zeros, but I want to insert rectangles (or circles) of 1's at certain positions. For example I want a 20x20 rectangle of 1's starting at position (621,499). Is there an easy way to do this without typing in each cell value?
i.e. I do not want to use A(x,y)=1 for a repetitive amount of times. I know I could use a for loop, but I prefer not to. Please help!

採用された回答

Walter Roberson
Walter Roberson 2014 年 2 月 19 日
Matrix(621:621+20-1, 499:499+20=1) = 1;

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by