How to plot a point on matlab?

In summary, the conversation discusses a problem with plotting a column vector, where a straight line is shown instead of a point. The solution is to use the command "plot(x,y 'o')" to plot points, and for multiple elements, "plot(x(1, :), x(2, :))". The user also mentions the possibility of extracting numbers from the column vector to plot them.
  • #1
theBEAST
364
0
I have attached a picture of my problem to this thread. When I plot the column vector
x=[1;1]
I get a straight line instead of a point, does anyone know how to fix this?
 

Attachments

  • Capture.PNG
    Capture.PNG
    10.7 KB · Views: 566
Physics news on Phys.org
  • #2
Code:
plot(x,y);
where (x,y) is a point.

To show points, also:
Code:
plot(x,y 'o');
 
  • #3
jhae2.718 said:
Code:
plot(x,y);
where (x,y) is a point.

To show points, also:
Code:
plot(x,y 'o');

Thanks but for this assignment I have to plot the x column vector that I get from doing another calculation that I did not show. Maybe I can extract the numbers out of the column but we have not been taught that.
 
  • #4
plot(x(1),x(2));

for multiple elements,
plot(x(1, :), x(2, :))
 
  • #5


I can provide some guidance on how to plot a point on MATLAB. Firstly, make sure you are using the correct syntax for plotting a point. In MATLAB, a point is represented by a single data point, not a column vector. So, instead of using x=[1;1], you should use x=1. This will plot a single point at the coordinates (1,1).

If you want to plot multiple points, you can use the plot function with two vectors, one for the x-coordinates and one for the y-coordinates. For example, if you want to plot the points (1,1) and (2,3), you can use the following code:

x = [1, 2];
y = [1, 3];
plot(x,y,'o') %the 'o' specifies that the points should be plotted as circles

This will plot two points on the same figure.

In regards to the issue of getting a straight line instead of a point, it could be due to the plot settings. You can try adjusting the plot properties such as the axis limits, plot style, and marker size to get a clearer visualization of the point.

Additionally, it is always helpful to consult the MATLAB documentation or online resources for further guidance on plotting points and customizing plots. I hope this helps in resolving your issue. Happy plotting!
 

1. How do I plot a single point on MATLAB?

To plot a single point on MATLAB, you can use the "plot" function with the x and y coordinates of the point as inputs. For example, if you want to plot the point (2,3), you would use the command "plot(2,3)".

2. Can I plot multiple points on MATLAB at once?

Yes, you can plot multiple points on MATLAB at once by specifying the x and y coordinates of each point in a vector. For example, if you want to plot the points (1,2), (3,4), and (5,6), you would use the command "plot([1,3,5],[2,4,6])".

3. How do I customize the appearance of the plotted point?

You can use the optional input arguments of the "plot" function to customize the appearance of the plotted point. For example, you can change the color, shape, and size of the point by specifying the "Color", "Marker", and "MarkerSize" arguments, respectively.

4. Can I plot a point with a label or text on it?

Yes, you can use the "text" function to add a label or text to a plotted point. This function takes the x and y coordinates of the point as well as the text to be displayed as inputs. For example, the command "text(2,3,'A')" would plot the point (2,3) and label it as "A".

5. Is it possible to plot a 3D point on MATLAB?

Yes, MATLAB has a "plot3" function that allows you to plot points in three-dimensional space. This function takes three inputs - the x, y, and z coordinates of the point - and can be used to plot multiple points as well.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
32
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
Back
Top