Horizontal histogram maker
This command will plot the elements of vector y (on the vertical axis of a figure) versus the elements of the vector x (on the horizontal axis of the figure).
HORIZONTAL HISTOGRAM MAKER CODE
This code can be entered in the MATLAB command window or run from an m-file. The basic syntax of the function call is shownīelow.
HORIZONTAL HISTOGRAM MAKER HOW TO
The plot command also happens to be one of the easiest functions to learn how to use. The number of books is discrete data, since books are counted.One of the most important functions in MATLAB is the plot function. The following data are the number of books bought by 50 part-time college students at ABC College. Construct a histogram and calculate the width of each bar or class interval. The sizes are continuous data since shoe size is measured. The following data are the shoe sizes of 50 male students. The following histogram displays the heights on the x-axis and relative frequency on the y-axis. The height 74 is in the interval 73.95–75.95. The heights 72 through 73.5 are in the interval 71.95–73.95.
The heights 70 through 71 are in the interval 69.95–71.95. The heights 68 through 69.5 are in the interval 67.95–69.95. The heights 66 through 67.5 are in the interval 65.95–67.95. The heights that are 64 through 64.5 are in the interval 63.95–65.95. The heights that are 63.5 are in the interval 61.95–63.95. The heights 60 through 61.5 inches are in the interval 59.95–61.95. For example, if there are 150 values of data, take the square root of 150 and round to 12 bars or intervals. A guideline that is followed by some for the width of a bar or class interval is to take the square root of the number of data values and then round to the nearest whole number, if necessary. For this example, using 1.76 as the width would also work. Rounding to the next number is often necessary even if it goes against the standard rules of rounding. Rounding up to two is one way to prevent a value from falling on a boundary. We will round up to two and make each bar or class interval two units wide.
The graph will have the same shape with either label. The vertical axis is labeled either frequency or relative frequency (or percent frequency or probability). The horizontal axis is labeled with what the data represents (for instance, distance from your home to school). It has both a horizontal axis and a vertical axis. A rule of thumb is to use a histogram when the data set consists of 100 values or more.Ī histogram consists of contiguous (adjoining) boxes. One advantage of a histogram is that it can readily display large data sets.