Why Does My MATLAB Plot Show a Line Instead of a Point? (2024)

  • Forums
  • Mathematics
  • MATLAB, Maple, Mathematica, LaTeX
  • MATLAB
  • Thread startertheBEAST
  • Start date
  • Tags
    MatlabPlotPoint

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

    10.7 KB· Views: 576

  • #3

theBEAST

364
0

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.

  • #5

alphy

1,403
1

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!

Related to Why Does My MATLAB Plot Show a Line Instead of a Point?

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[~,~,~,~,~,~,~,~,spec] Too many output arguments...

  • MATLAB, Maple, Mathematica, LaTeX
    Replies
    5
    Views
    498

    MATLABPlotting Reaction Rate vs Temperature with MATLAB

    • MATLAB, Maple, Mathematica, LaTeX
      Replies
      4
      Views
      1K

      MATLABHow to Plot a 4th Degree Polynomial in MATLAB: Step-by-Step Guide

      • MATLAB, Maple, Mathematica, LaTeX
        Replies
        7
        Views
        1K

        MATLABFEM, Matlab and the modes of an element

        • MATLAB, Maple, Mathematica, LaTeX
          Replies
          32
          Views
          2K

          MATLABHow to Plot y=sin(x)/log(x) in MATLAB Without Imaginary Errors?

          • MATLAB, Maple, Mathematica, LaTeX
            Replies
            11
            Views
            2K

            MATLABClosed form not the same as the discrete form

            • MATLAB, Maple, Mathematica, LaTeX
              Replies
              1
              Views
              1K

              MATLABMATLAB: Fluid Flow - Curl of a Vector Field

              • MATLAB, Maple, Mathematica, LaTeX
                Replies
                2
                Views
                1K

                MATLABHow to change the frequency values inside a time domain signal phase

                • MATLAB, Maple, Mathematica, LaTeX
                  Replies
                  1
                  Views
                  869

                  MATLABReplacing the "quad" function with "integral" doesn't work in Matlab

                  • MATLAB, Maple, Mathematica, LaTeX
                    Replies
                    1
                    Views
                    3K

                    MATLABA Lorenz's system of ODEs doesn't get executed in Matlab

                    • MATLAB, Maple, Mathematica, LaTeX
                      Replies
                      5
                      Views
                      2K
                      • Forums
                      • Mathematics
                      • MATLAB, Maple, Mathematica, LaTeX
                      Why Does My MATLAB Plot Show a Line Instead of a Point? (2024)

                      FAQs

                      How to specify a point on a graph in MATLAB? ›

                      [ xi , yi ] = getpts lets you choose points in the current figure using the mouse. When you finish selecting points, getpts returns the coordinates of the selected points in xi and yi . Use normal button clicks to add points. A shift-, right-, or double-click adds a final point and ends the selection.

                      How do you show plot points in MATLAB? ›

                      plot( points , ax ) plots points in the specified axis. plot( points , ax ,Name=Value) specifies options using one or more name-value arguments in addition to any combination of arguments from previous syntaxes. For example, plot(ShowOrientation=true) renders the orientation in the display plot.

                      How do you plot a curve instead of a line in MATLAB? ›

                      The MATLAB routines for plotting curves instead of straight lines are:
                      1. viscircles() (Image Processing Toolbox)
                      2. rectangle() (basic MATLAB) -- despite its name, you can create ovals and circles from it.
                      3. scatter() or plot() with markershape 'o' and large marker size.
                      Jul 27, 2021

                      How to display values in plot in MATLAB? ›

                      plot( ax ,___) displays the plot in the target axes. Specify the axes as the first argument in any of the previous syntaxes. plot(___, Name,Value ) specifies Line properties using one or more name-value arguments. The properties apply to all the plotted lines.

                      How do you state a point on a graph? ›

                      Step 1: Identify the point in question, (x,y). Step 2: Determine its x-coordinate, which will be the horizontal distance from the origin. Step 3: Determine its y-coordinate, which will be the vertical distance from the origin. Step 4: Plot or label the point (depending on what the question is asking).

                      How to plot data points in Matlab no line? ›

                      You can use ANY line plot and use 'linestyle','none' option to remove lines.

                      How to plot visualization in Matlab? ›

                      Visualize Data with MATLAB
                      1. Click Apps > MATLAB Visualizations.
                      2. Click New to start your visualization.
                      3. Select a template or an example with sample code, which you can run and explore the results.
                      4. Click Create.

                      How to label points in Matlab plot? ›

                      text( x , y , txt ) adds a text description to one or more data points in the current axes using the text specified by txt . To add text to one point, specify x and y as scalars. To add text to multiple points, specify x and y as vectors with equal length. text( x , y , z , txt ) positions the text in 3-D coordinates.

                      How to plot normal in MATLAB? ›

                      Generate a Normal Probability Plot

                      Generate random sample data from a normal distribution with mu = 10 and sigma = 1 . rng default; % For reproducibility x = normrnd(10,1,25,1); Create a normal probability plot of the sample data. The plot indicates that the data follows a normal distribution.

                      How to get smooth plot in MATLAB? ›

                      Accepted Answer

                      plot(xx, yy1, 'r-'); yy2 = interp1(x, y, xx, 'spline'); plot(xx, yy2, 'b-'); yy3 = interp1(x, y, xx, 'makima');

                      How do you fit a curve to a point in MATLAB? ›

                      Curve Fitting
                      1. Load some data at the MATLAB® command line. ...
                      2. Open the Curve Fitter app. ...
                      3. In the Curve Fitter app, on the Curve Fitter tab, in the Data section, click Select Data. ...
                      4. Choose a different model type from the fit gallery in the Fit Type section of the Curve Fitter tab.

                      How to plot a graph in MATLAB with points? ›

                      Direct link to this answer
                      1. plot(w, X, 'b-', 'LineWidth', 2);
                      2. grid on;
                      3. xlabel('w', 'FontSize', 15);
                      4. ylabel('X', 'FontSize', 15);
                      5. hold on;
                      6. plot(w, X, 'r.', ' LineWidth', 2, 'MarkerSize', 25);
                      Mar 7, 2020

                      How to display result in MATLAB? ›

                      Use disp to display the result. Alice will be 12 this year. Use sprintf to create text, and then display it with disp .

                      How do I change the plot view in MATLAB? ›

                      Change the View Using a Vector

                      Get the azimuth and elevation angles for this plot. Change the view by specifying v as the x- y- and z-coordinates of a vector, and return the new azimuth and elevation angles. The new angles are based on a unit vector pointing in the same direction as v .

                      How to mark certain points on a graph in Matlab? ›

                      You can add a marker in the following ways:
                      1. Plot the point itself: hold on % to plot on the current figure. ...
                      2. Specify a value for the 'MarkerIndices' property in plot to plot a line with markers at specific data points. ...
                      3. Specify a 1-d array for the 'MarkerIndices' property to add multiple markers to the plotted line.
                      Feb 27, 2014

                      How do you label a specific point on a graph in Matlab? ›

                      To add text to one point, specify x and y as scalars. To add text to multiple points, specify x and y as vectors with equal length. text( x , y , z , txt ) positions the text in 3-D coordinates.

                      How do you highlight a specific point in a plot in Matlab? ›

                      There are 3 steps to this process.
                      1. Get the current point of the cursor.
                      2. Find the closest point to the cursor when the cursor is within the axes.
                      3. Temporarily highlight the point.
                      Nov 15, 2021

                      How do you pin a point on a graph in Matlab? ›

                      To pin an object, first enable pinning mode by clicking the pin object icon in the plot edit toolbar or select Pin Object from the Edit menu. Then click the point you want to pin. To unpin an object, right-click to display the context menu and select Unpin.

                      Top Articles
                      Latest Posts
                      Article information

                      Author: Frankie Dare

                      Last Updated:

                      Views: 6156

                      Rating: 4.2 / 5 (73 voted)

                      Reviews: 88% of readers found this page helpful

                      Author information

                      Name: Frankie Dare

                      Birthday: 2000-01-27

                      Address: Suite 313 45115 Caridad Freeway, Port Barabaraville, MS 66713

                      Phone: +3769542039359

                      Job: Sales Manager

                      Hobby: Baton twirling, Stand-up comedy, Leather crafting, Rugby, tabletop games, Jigsaw puzzles, Air sports

                      Introduction: My name is Frankie Dare, I am a funny, beautiful, proud, fair, pleasant, cheerful, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.