# MATLAB Separate Points for Plotting

• MATLAB
• strokebow
In summary, "MATLAB Separate Points for Plotting" refers to creating a scatter plot in MATLAB with separate markers for each data point. This can be achieved by using the "scatter" function and customizing the marker properties. Multiple sets of separate points can be plotted in one graph using the "hold" function and a legend can be added using the "legend" function.

#### strokebow

Hi,

I have generated 1000 data points.
I have assigned them a class (1 or 0) depending if they are above or below a decision boundary.

I want to plot the data on a graph with the class 1 data points in one colour and the class 0 data points in another.

any ideasa how I can do this please.

Thanks!

Hi there,

Thank you for sharing your question. In order to plot your data points with different colors based on their assigned class, you can use the "scatter" function in MATLAB. This function allows you to specify the x and y coordinates of your data points, as well as their color and shape. Here is an example code:

x = randn(1000,1); % generate 1000 random data points for x
y = randn(1000,1); % generate 1000 random data points for y
class = randi([0 1],1000,1); % randomly assign class 0 or 1 to each data point

% plot class 1 data points in red
scatter(x(class==1),y(class==1),'r');
hold on; % keeps the current plot and adds new elements
% plot class 0 data points in blue
scatter(x(class==0),y(class==0),'b');
legend('Class 1','Class 0'); % add legend to the plot
xlabel('X'); % label x-axis
ylabel('Y'); % label y-axis
title('Plot of Data Points with Different Classes'); % add title to the plot

I hope this helps! Please let me know if you have any further questions. Good luck with your project.

## 1. What is "MATLAB Separate Points for Plotting"?

"MATLAB Separate Points for Plotting" refers to the process of creating a scatter plot in MATLAB where each data point is represented by a separate marker on the graph.

## 2. How do I separate points for plotting in MATLAB?

To separate points for plotting in MATLAB, you can use the "scatter" function and specify a different marker for each data point, such as a dot or asterisk. This will create a scatter plot with separate points for each data point.

## 3. Can I customize the markers for separate points in MATLAB?

Yes, you can customize the markers for separate points in MATLAB by specifying the marker type, size, color, and other properties in the "scatter" function. This allows you to create a visually appealing scatter plot with unique markers for each data point.

## 4. Is it possible to plot multiple sets of separate points in one graph in MATLAB?

Yes, you can plot multiple sets of separate points in one graph in MATLAB by using the "hold" function. This allows you to add additional data sets to an existing plot, creating a more comprehensive visualization.

## 5. Can I add a legend to a scatter plot with separate points in MATLAB?

Yes, you can add a legend to a scatter plot with separate points in MATLAB by using the "legend" function. This allows you to label each data set and make it easier to interpret the graph.