フィルターのクリア

Concentric Squares with matricies

1 回表示 (過去 30 日間)
hoennnoodle
hoennnoodle 2021 年 2 月 22 日
回答済み: J. Alex Lee 2021 年 2 月 23 日
Hi guys, I'm new to MATLAB and I'm trying to figure out something with plotting images.
I want to plot a set of concentric squares similar to this image but I'm kind of lost about how to approach the problem. I want an image of height H with the difference in height between each layer of the square D which I can use a matrix to represent (I'm thinking of starting with a matrix of zeros(H)) but I don't know how to get the matrix to alternate between 'rings' of ones and zeros for the black and white bands. Any help is appreciated.
Something like this, but for an arbitrary height H and difference D:
img = [0 0 0 0 0;
0 1 1 1 0;
0 1 0 1 0;
0 1 1 1 0
0 0 0 0 0];
imagesc(img)
colormap gray

採用された回答

J. Alex Lee
J. Alex Lee 2021 年 2 月 23 日
Try looking into padarray (or arraypad I can't remember...). I think you can apply successively to achieve what you want

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by