You can use the plot()
function to plot a line in MATLAB.
To plot a line that has a length of 40 along the y axis and offset 20 in the x axis, you can define two points (x1,y1) and (x2,y2) that define the line:
main.m35 chars5 lines
Then you can create a new figure and plot the line using the plot()
function:
main.m69 chars3 lines
The first argument to plot()
is a vector of x coordinates for each point on the line, and the second argument is a vector of y coordinates.
The square brackets []
concatenate the x and y coordinates into two rows, so that plot()
reads them as pairs of (x,y) coordinates.
This should produce a plot with a single vertical line segment that is 40 units long and offset 20 units from the y axis.
gistlibby LogSnag