MATLAB: Add coordinate points to a grid

gridmeshgrid

Hi, I need help. Im trying to create a grid (map of a ground) 200m x 300m and then I need to add some points in the grid. I have the coordinates of the points, but I dont know how to do it. I did the grid with the command [X,Y]= meshgrid() but it created a grid with lines, not an empty grid. So, I need an empty grid in which I can add the points. Thanks so much, Vanessa

Best Answer

Why can't you just do
% Create empty grid. No lines at all, or any points at all.
myGrid = zeros(rows, columns);
% You say you have existing coordinates already.
% Let's assume they are in arrays called x and y
% and have values that correspond to rows and columns.
% Place them in the grid with a value of 1
for k = 1 : length(x)
myGrid(y(k), x(k)) = 1;
end