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 visualization. When plotting data it is often necessary to plot a horizontal line through a specific point to emphasize 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.

## Step 1

Clear all active variables in the workspace by typing clear all in the command windows.

## Step 2

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.

## Step 3

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.

## Step 4

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.

### Tip

A vertical line can be plotted in the same manor by keeping the x-values constant and changing the y values.