The difficulty with a for loop is calculating the correct pixels to write into. There is a standard algorithm for this though: see Bresenham's Line Algorithm.
You could also be a bit lazy and use an existing tool.
You could use poly2mask and supply it with the endpoint coordinates and the array size. A logical mask would be output that is true at each location along the path. You would then set those locations to the desired color.
I was going to mention another possibility but I think the above is much easier.
If I recall there is also a routine in the Computer Vision Toolbox that can be used to draw a line inside an array.