Azzera filtri
Azzera filtri

How to plot a matrix in a checkerboard style

3 visualizzazioni (ultimi 30 giorni)
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)])

Risposta accettata

DGM
DGM il 28 Nov 2021
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

Più risposte (0)

Categorie

Scopri di più su Read, Write, and Modify Image in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by