## Matlab Tutorial 4: Data Analysis and Statistics with Matlab

This tutorial covers data analysis and statistics using Matlab.

### Histogram Charts in Matlab

The elements of a vector can be displayed with bars or histograms. To create a histogram you need to divide the elements in to classes and count how many elements that belongs to each class. Then present them as rectangular bars in a diagram. The height of the rectangle is equal to the number of elements in that class. Read the vector.

**hist(x)**Plots a histogram with 10 intervals (default) for the elements in vector x.**hist(x,n)**Plots a histogram with n intervals for the elements in vector x.**hist(x,y)**Plots a histogram with arbitrary intervals. These are given in vector x.

Introduce a histogram with 15 intervals for the vector x above. It is rather difficult to see how long the intervals are. Maybe its better to introduce a histogram with 6 intervals since we know the difference between the maximum and minimum value.

>> hist(x,6) |

If we don’t know the dataset, we can define the intervals that we are interested to have in the histogram. Suppose we want the integer values between 0 and 10.

>> y=0:10; |

>> bar(x),grid >> title('bar for vector x') |

cabo San lucas rentals by owner — March 3, 2015 @ 12:27 am

Thanks for sharing your thoughts about covariance.

Regards