A horizontal line is a line whose points all share the same y-value. A horizontal line is perpendicular to a vertical line, whose points all share the same x-value. MATLAB is a technical computer program use for data processing and data visualisation. When plotting data it is often necessary to plot a horizontal line through a specific point to emphasise a particular point or area. Below shows an example of how to plot a horizontal line in MATLAB by defining the x and y-values that the horizontal line will pass through.
- Skill level:
- Moderately Easy
Other People Are Reading
Clear all active variables in the workspace by typing clear all in the command windows.
Define the y-intercept value that the line will pass through. If the line is not meant to pass through the y-axis, define the height of the horizontal line. In this example, the height of the horizontal line will be 3, therefore type y=3 into the command window.
Define the starting and ending points of the horizontal line by inputting the x-axis values into the command window. In this example, the line will start at -4 and end at 4 on the x-axis. Therefore enter x1=-4 and x2=4 into the command window.
Plot the horizontal line by entering plot([x1, x2], [y1, y1]) into the command window. This will plot a horizontal line that runs from the points (-4,3) to (4,3). Since both y values are the same, the line will be horizontal.
Tips and warnings
- A vertical line can be plotted in the same manor by keeping the x-values constant and changing the y values.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for