How can I populate a matrix of zeros, with a value of 1 at specific rows and columns?
1 view (last 30 days)
Show older comments
I created a for loop that runs through rows and columns of a matrix and adds the x positions where the conditions are met to a new vector x and the y positions where the conditions are met to a new vector y. This vector gives me x and y coordinates that I want to plot. I now want to use these x and y positions to populate an mxn matrix with the value 1, for each of these x,y positions. How would I do this?
3 Comments
Matt J
on 2 Dec 2018
Simi Srfati's comment moved here:
I am basically trying to simulate the idea that when pacman "eats" one of the dots.
My plan to do this was to plot the dots in all of the positions that pacman is allowed to move in the game board. If the position of the pacman is equal to the position of where the dot is plotted, then the dot should dissapear. (Basically by setting the x and y positions at that index to an empty set, and then updating the x and y values on plot using set(x,'XData',y, 'YData'). I am just stuck on how I can see if the position of the pacman is the same as the position of the dot.
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!