MATLAB: Separate Points for Plotting

In summary, the conversation is about generating 1000 data points and assigning them a class based on a decision boundary. The speaker is looking for ideas on how to plot the data on a graph with the two classes represented by different colors.
  • #1
strokebow
123
0
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!
 
Physics news on Phys.org
  • #2
strokebow said:
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!

Please don't cross-post to multiple subforums. I've already replied in your other thread:
https://www.physicsforums.com/showthread.php?t=310468
 
  • #3


Hello,

Thank you for reaching out. In order to plot the data points with their assigned classes, you can use the "scatter" function in MATLAB. This function allows you to specify the x and y coordinates of the data points, as well as the color and shape of the markers. You can use a conditional statement to assign different colors to the data points based on their class, and then use the "hold on" command to plot both sets of points on the same graph. Here is an example code:

x = %insert your x coordinates here
y = %insert your y coordinates here
class = %insert your class assignments here

%plot class 1 points in red
scatter(x(class==1), y(class==1), 'r')

%plot class 0 points in blue
scatter(x(class==0), y(class==0), 'b')

%add labels and legend
xlabel('x')
ylabel('y')
legend('Class 1', 'Class 0')

I hope this helps. Let me know if you have any further questions. Happy plotting!
 

Related to MATLAB: Separate Points for Plotting

1. How do I separate points for plotting in MATLAB?

To separate points for plotting in MATLAB, you can use the "hold on" command. This tells MATLAB to keep the current plot and add new plots to it without erasing the existing plot. Alternatively, you can use the "hold off" command to turn off this functionality.

2. Can I plot multiple sets of points in one plot using MATLAB?

Yes, you can plot multiple sets of points in one plot using MATLAB by using the "hold on" command. This allows you to add new plots to the existing plot without erasing it. You can also use the "subplot" function to create multiple plots within one figure.

3. How do I change the color of points in a plot using MATLAB?

To change the color of points in a plot using MATLAB, you can use the "color" parameter when specifying the plot. For example, "plot(x, y, 'color', 'red')" will plot the points in red. You can also use the "colormap" function to specify a color scheme for your plot.

4. Is it possible to plot different types of points in one plot using MATLAB?

Yes, it is possible to plot different types of points in one plot using MATLAB. You can use the "plot" function to specify the type of point you want to plot, such as circles, squares, or triangles. You can also use the "scatter" function to plot different types of points with different colors and sizes.

5. How do I label the points in a plot using MATLAB?

To label points in a plot using MATLAB, you can use the "text" function. This allows you to specify the coordinates and text for each label. Alternatively, you can use the "legend" function to create a legend for your plot, which will label each set of points with a corresponding label.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
233
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
942
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
10
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Back
Top