You can plot points in MATLAB using the scatter
function. The scatter function takes two arguments, representing the x-coordinates and y-coordinates of the data points.
For example, to plot the points (1,2), (3,4), and (5,6), you could use the following commands:
x = [1 3 5];
y = [2 4 6];
scatter(x, y)
In addition to the x- and y-coordinates, the scatter
function also accepts a number of optional arguments that allow you to customize the appearance of the plot. For example, you can specify the color, size, and shape of the markers using the 'Color'
, 'SizeData'
, and 'Marker'
properties.
Here is an example that creates a scatter plot with red markers of size 10 and square shape:
x = [1 3 5];
y = [2 4 6];
scatter(x, y, 'Color', 'r', 'SizeData', 10, 'Marker', 's')
You can also add labels, titles, and a legend to your scatter plot. For example, the following commands will add a title, axis labels, and a legend to the previous plot:
x = [1 3 5];
y = [2 4 6];
scatter(x, y, 'Color', 'r', 'SizeData', 10, 'Marker', 's')
title('Scatter Plot Example')
xlabel('x')
ylabel('y')
legend('data')
You can plot points in MATLAB using the scatter function. The scatter function takes two arguments, representing the x-coordinates and y-coordinates of the data points.
Related tutorials curated for you
How to create a scatter plot in MATLAB
How to plot points in MATLAB
MATLAB linspace
How to plot a Bode in MATLAB
Plot markers in MATLAB
MATLAB subplot
How to create a surface plot in MATLAB
How to plot a legend in MATLAB
How to plot a line in MATLAB
How to plot colors in MATLAB
How to create a 3D plot in MATLAB