MATLAB: Convert xyz data to 2-d bw image, no interpolation

2dgridxyz

Hi —
I've been reading lots of somewhat similar questions/answers but most seem to deal with interpolating scattered data (i.e. creating surfaces).
I simply would like to convert a set of points (x,y) each with a value of 1 to a bw image. So just a point vector to raster conversion more or less where the resolution is just 1.
Also, I would like to set the dimensions of the output matrix manually such that it can be arbitrarily larger than the extents of the x,y data.
This seems like it should be straightforward but I'm stuck… Any help is appreciated.
Thanks, Mike

Best Answer

Use zeros() to preallocate an array of a desired size. Then you can always just use a nested for loop (two for's) to assign the values for each x and y. Be aware that x=column and y = row so it's array(y, x), not array(x,y).