how to scatter plot in matlab

To create a scatter plot in MATLAB, you can use the scatter function. The scatter function takes two vectors of the same length and creates a scatter plot of the points with one vector representing the x-axis values and the other vector representing the y-axis values.

Here's an example:

main.m
x = [1, 2, 3, 4, 5];
y = [10, 5, 8, 3, 6];
scatter(x, y);
58 chars
4 lines

This code will create a scatter plot with the points (1, 10), (2, 5), (3, 8), (4, 3), and (5, 6).

You can also customize the appearance of the scatter plot using additional arguments to the scatter function. For example, you can change the color and size of the markers:

main.m
x = [1, 2, 3, 4, 5];
y = [10, 5, 8, 3, 6];
marker_size = 50;
marker_color = 'red';
scatter(x, y, marker_size, marker_color);
125 chars
6 lines

This code will create a scatter plot with red markers that are 50 points in size.

gistlibby LogSnag