To create a scatter plot with interconnected points in MATLAB you can use the plot
function. To add new points every time you run the script, you can define the x and y values as arrays and append the new values to these arrays each time the script is run. Here's an example script:
main.m183 chars13 lines
In this example, the initial x and y values are defined using arrays with four elements each. The newX
and newY
arrays represent two new data points that we want to add to the plot.
We then use the concatenation operator []
to append the newX
and newY
values to the existing x
and y
arrays. Finally, we create the plot using the plot
function with the '-o'
option to specify that we want lines connecting the points and circles at the data points.
You can run this script multiple times to add as many new data points as you want to the plot.
gistlibby LogSnag