Plotting a variable as a function of the iteration number in a for loop
Mostrar comentarios más antiguos
Hi,
Basically I have loop, within which is a 12X12 array of zeros and ones. For each cycle of the loop I need to sum the value of the array(which I am able to do) and then plot this value against the iteration/loop number.
Obviously the value of the array changes for each loop so I am a bit stuck as to how to plot the graph.
Eg. Do I output the values for each loop to a seperate new array/file, which I then draw upon at the end of the loop to create the graph? Or is there some way to construct a graph in stages as the program loops-essentially holding the plot figure and adding new points to the existing plot for each iteration.
Any help would be very much appreciated! If I have not explained very well just let me know and I can try and explain further/provide code snippets.
Thanks in advance,
Mike Scott
1 comentario
Oleg Komarov
el 11 de Abr. de 2011
Is the loop unavoidable?
Respuesta aceptada
Más respuestas (1)
vega valentine
el 11 de Abr. de 2011
0 votos
don't you just have to plot it outside the loop? I think what you need to do is just store every values you needed in every loop into a separate array/variable, and then after the looping is done, you can plot that array/variable.
2 comentarios
Mike Scott
el 11 de Abr. de 2011
Oleg Komarov
el 11 de Abr. de 2011
Post the code you're using, formatting with the code button.
Categorías
Más información sobre Conway's Game of Life en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!