Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How to create a line in matlab matlab?


Asked by Sincere Fitzpatrick on Dec 07, 2021 FAQ



Create x and y as vectors. Then plot y versus x using the low-level version of the line function. Draw a red, dashed line between the points (1,2) and (9,12). Set the Color and LineStyle properties as name-value pairs. First, draw a line from the point (3,15) to (2,12) and return the Line object. Then change the line to a green, dashed line.
Also,
line (x,y) plots a line in the current axes using the data in vectors x and y. If either x or y, or both are matrices, then line draws multiple lines. Unlike the plot function, line adds the line to the current axes without deleting other graphics objects or resetting axes properties.
Additionally, If x and y are both vectors with the same length, then line plots a single line. If x and y are matrices with the same size, then line plots multiple lines. The function plots columns of y versus x. If one of x or y is a vector and the other is a matrix, then line plots multiple lines.
Also Know,
To make the code easier to read and to make MATLAB wait while you type more commands, hit shift-enter as you enter commands. This adds a new line in the Command Window without executing the code that has already been typed.
In addition,
If one of X or Y is a scalar and the other is either a scalar or a vector, then the plot function plots discrete points. However, to see the points you must specify a marker symbol, for example, plot(X,Y,'o'). plot(X,Y,LineSpec) sets the line style, marker symbol, and color.