フィルターのクリア

How to plot a matrix in a checkerboard style

3 ビュー (過去 30 日間)
Jimmy Neutron
Jimmy Neutron 2021 年 11 月 28 日
回答済み: DGM 2021 年 11 月 28 日
I am trying to make my matrix Im look like the image below. I have tried playing around with the grid size, but to no avail...
Im = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 1 0 0 0 1 1 0 0 0 0 0 0 0;
0 1 0 0 0 0 1 0 0 0 0 1 0 0 0;
0 1 0 1 1 0 1 0 0 0 0 1 1 1 0;
0 0 0 1 1 0 1 0 0 0 0 1 0 0 0;
0 0 1 0 1 0 1 1 0 0 0 0 0 0 0;
0 0 0 1 1 0 1 1 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 1 0 0 0 0 0 1 0;
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0;
0 0 0 1 0 0 0 1 0 0 0 1 1 0 0;
0 0 1 1 0 0 1 1 0 0 0 1 0 0 0;
0 0 0 1 0 0 1 1 0 0 0 1 1 0 0;
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
];
figure
imagesc(Im)
grid on
set(gca,'xtick',[0:1:length(Im)])
set(gca,'ytick',[0:1:length(Im)])

採用された回答

DGM
DGM 2021 年 11 月 28 日
Something like this should be a start:
Im = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 1 0 0 0 1 1 0 0 0 0 0 0 0;
0 1 0 0 0 0 1 0 0 0 0 1 0 0 0;
0 1 0 1 1 0 1 0 0 0 0 1 1 1 0;
0 0 0 1 1 0 1 0 0 0 0 1 0 0 0;
0 0 1 0 1 0 1 1 0 0 0 0 0 0 0;
0 0 0 1 1 0 1 1 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 1 0 0 0 0 0 1 0;
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0;
0 0 0 1 0 0 0 1 0 0 0 1 1 0 0;
0 0 1 1 0 0 1 1 0 0 0 1 0 0 0;
0 0 0 1 0 0 1 1 0 0 0 1 1 0 0;
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
];
hp = pcolor(padarray(Im,[1 1],'replicate','post'));
hp.EdgeColor = [1 0 0];
hp.LineWidth = 2;
colormap(gray(2))
set(gca,'ydir','reverse')
axis equal

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRead, Write, and Modify Image についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by