How to Plot Points in MATLAB
The technical computing software MATLAB stores, processes and analyzes data contained in arrays and matrices. After manipulating the data to its final form, plotting the data makes it easier to visualize the data to identify trends and other patterns. Plotting multiple data sets together helps correlate the trends between the two. There are many ways of representing the data on a plot, including using individual markers to represent unique data points or connecting each data point with a line. Learn how to represent the data using individual markers in a MATLAB plot.
Clear all active variables within the workspace by entering "Clear All" into the Command window.
Create two arrays of data as sample points to plot, with one array representing the x-data, the other the y-data. For example, input "x=1:1:10." This creates the array [1 2 3 4 5 6 7 8 9 10]. Input "y=2:2:20" to create y-data. This will generate the array [2 4 5 6 8 10 12 14 16 18 20].
Enter into the command window "plot(x, y, ".") to plot the points. The "." in the code places a "." at each coordinate of the x-y matrix. For instance, a point will be placed at (1,2) and (2,4).
Click on the "Show Plot Tools and Dock Figure" in the figure menu to change the marker type. Click on one individual marker and select an appropriate icon under the pull-down menu labeled "marker."
Tips & Warnings
- Omitting the "." from the code in step 3 will connect all points by a continuous line.
- You can also change the thickness and color of the marker in the "Show Plot Tools and Dock Figure" menu.