mardi 8 novembre 2016

A blank grid with a random green place in Matlab

I created a 100x100 lattice using this code :

L=ones(101,1)*(1:101);
for i=2:101
    for j=1:101
        L(i,j)=10*(i-1)+j;
    end
end
M=L;
x=randi([1 100]);
y=randi([1 100]);
M(x,y)=0;

I want to generate a blank 100x100 grid with the case containing "0" in green.

Note: I tried this method but it doesn't work

map1 = [1 1 1]; 
colormap(map1);
pcolor(L)

map2 = [0 1 0];
colormap(map2);
pcolor(M(x,y))




Aucun commentaire:

Enregistrer un commentaire