在MATLAB中根据真/假值绘制正方形网格



我想在MATLAB中创建一个等平方网格。我有一个矩阵,它存储混合值为1或0。我希望1代表黑色方块,0代表白色,白色轮廓封装黑色方块以获得清晰度/黑色网格线代表白色方框。

我用了这个线程

http://stackoverflow.com/questions/8711971/plotting-a-grid-of-squares-in-matlab

然而,在任何一个轴上都不需要单位或值(我代表一些有阴影/无阴影的光伏面板)。

伪代码类似于:

   For(x row of variable, y column of variable)
     If (variablename(x,y)) value = 1
       draw a black square with white outline
    elseif (variablename(x,y)) value = 0
       draw a white square with black outline
       end
    end

为什么不直接使用:

n = 5;
S = round(rand(n));
imagesc(S);
colormap(gray);
grid on;

最新更新