11-15-2021 09:55 AM
Hello! I wanted to see a graph plotted point by point so I built 2 arrays x and y to track the process, However, my attempt was unsuccessful. Here is what I did vs what my professor did but I don't understand why what I did was wrong. Can anyone please explain it a bit thoroughly so I have a good understanding of how to work with arrays. Thank you so much in advance!!
How I did it:
what my professor did:
(some more context:) Plotting on an XY-Graph point by point
In order to see the graph being plotted point by point, we have to send the x and y arrays to
the XY-graph at every increment.
For this reason we shall start with two empty arrays initializing the x and y values. At every iteration
we add the new values using insert to array to these arrays and plot them on the XY-graph.
Solved! Go to Solution.
11-15-2021 11:34 AM
@Lauren.jpg wrote:
Hello! I wanted to see a graph plotted point by point so I built 2 arrays x and y to track the process, However, my attempt was unsuccessful. Here is what I did vs what my professor did but I don't understand why what I did was wrong. Can anyone please explain it a bit thoroughly so I have a good understanding of how to work with arrays. Thank you so much in advance!!
How I did it:
what my professor did:
(some more context:) Plotting on an XY-Graph point by point
In order to see the graph being plotted point by point, we have to send the x and y arrays to
the XY-graph at every increment.
For this reason we shall start with two empty arrays initializing the x and y values. At every iteration
we add the new values using insert to array to these arrays and plot them on the XY-graph.
In your effort, you are creating a new array of one element with each iteration, for both the x and y axes and sending them to the graph. I suspect you are seeing a single dot traversing a sine pattern. What you need to do is find a way to add on the the end of the existing arrays, which is what your professor had done.
It is awkward to do it with an XY Graph because of this. Your way would work for a chart, though.
11-15-2021 03:10 PM
Thank you so much!! That was very informative!! I have a few questions left:
>>why did we use an array constant instead of an array indicator?And why is it placed outside the loop?
>>I'm also facing issues with understanding the wiring of the index in insert array.
Hope you can kindly clear up some of the confusion
Thank you so much in advance!!
11-15-2021 03:27 PM
Hi Lauren,
@Lauren.jpg wrote:
1. why did we use an array constant instead of an array indicator?And why is it placed outside the loop?
2. I'm also facing issues with understanding the wiring of the index in insert array.