Friday, 5 August 2016

MATLAB Programming 50 - bar charts


Drawing Bar Charts


The bar command draws a two dimensional bar chart. Let us take up an example to demonstrate the idea.

Example


Let us have an imaginary classroom with 10 students. We know the percent of marks obtained by these students are 75, 58, 90, 87, 50, 85, 92, 75, 60 and 95. We will draw the bar chart for this data.


Create a script file and type the following code:


y = [75 91 105 123.5 131 150 179 203 226 249 281.5];
bar(y)


When you run the file, MATLAB displays the following bar chart:





No comments:

Post a Comment