How to draw and delete a line in a graph

1 visualización (últimos 30 días)
Luigi Siviello
Luigi Siviello el 1 de Dic. de 2017
Comentada: dpb el 1 de Dic. de 2017
Hi guys, I have a network with n nodes, therefore I have an adjacency matrix A for the network. Since each node of the network moves itself in the time, in each instant they are in a different position e for this reason the matrix A changes. I wish to draw a circular region and all my network (nodes and edges) in a single graph, but I would want the following things: 1) for each step, the region have to always be visible 2) for each step, the edges I have drawn in the previous time have to be deleted and I want to draw the new edges
I try to plot thanks to the "line" command, but step by step the lines overlap. I don't know how to do it :( Can you help me please? Thanks to all

Respuesta aceptada

dpb
dpb el 1 de Dic. de 2017
  1. for each step, the region have to always be visible -- the plot axes will auto-range to include the data. If the magnitude of values decreases markedly, however, you may need to decrease the xlim|ylim ranges manually,
  2. for each step, the edges I have drawn in the previous time have to be deleted - save the line handle(s) of each line when calling line and then use that handle variable to delete desired line(s). Be sure to use an array and not overwrite a given handle variable if it is not deleted prior to drawing a subsequent line or you'll lose access to that line other than by "handle diving" to recover it.
  2 comentarios
Luigi Siviello
Luigi Siviello el 1 de Dic. de 2017
Thank you. I solved the problem in a simplified way: before plotting a new line, I clear the previous plot thanks to the command "clf"
dpb
dpb el 1 de Dic. de 2017
That's a "sledge hammer for a fly" approach...simply delete the line handle as outlined above.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Networks en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by