Moving points on a graph?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi (I'm sort of new to Matlab) - I'm having a lot of trouble plotting (n=10) points on a graph to move randomly on a graph. I know how to plot them, but making them move about is what is stumping me. Any assistance would help greatly!
Just in case I wasn't very specific haha I created a gif on Photoshop to kind of clear things up:
Basically what I am trying to eventually do is that there are two diffrent types of dots: Black dots are 'piggies' or 'prey' and the Red dots are 'birds' or 'predators.' As the "Birds" eat these "Piggies" you can notice they increase in size. You will also notice the "Piggies" just move in randomly spots on the graph while the "Birds" try to chase them down.
Thanks!
0 commentaires
Réponses (2)
Les Beckham
le 9 Jan 2016
If you search the Matlab File Exchange for 'game of life' you will find many implementations of a predator/prey 'simulation' that may give you inspiration.
In general, the way to update points on a graph is to update the 'Xdata' and 'Ydata' for the existing line object(s). Check the docs for line properties.
Good luck.
0 commentaires
Walter Roberson
le 9 Jan 2016
If you have R2014b or later you can use animatedline(); see http://uk.mathworks.com/matlabcentral/answers/263148-delete-points-after-a-certian-i
However, animatedline() would not allow for different marker sizes.
To support different marker sizes for different points, use scatter(). Once you create the scatterseries object, you can set its XData, YData and SizeData properties
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!