Thursday 8 December 2011

Matlab Bar chart Example, Matlab 3D Bar chart Example

Bar chart is one of best and stylish plot in matlab.Bar chart mainly used in comparison and Histogram operation.in bar chart can supported 2d and 3d matrix data's,While bar char displays choose different colors of bars generated.This color choose randomly in bar chart function,In this chart use different properties like as normal plot properties.The basic syntax as follows.
>>bar(x,Y)% for 2d bar chart
>>
bar(x,Y,z)% for 3d bar chart

In bar chat example as follows.

>> x = rand(10,1);
>> y = rand(10,1);
>> data = [x y];
>> bar(data)
>> legend('X data','Y data')



In this example x and y has two different data s,This data s must same length of size,data variable to combine two classes of data s.Then we plot the data use bar function.Finally we set the legend of our classes.We got finally follows output



In 3d bar chart as following example to use plot.

>> x = rand(10,1);
>>
y = rand(10,1);
>> z = rand(10,1);
>> data = [x y z];
>> bar3(data)

Here we generate random data s of x,y and z ,then all of them combine one single data s then we plot the data s .Here also we use legend,we get the result as follow.


Kindly Bookmark and Share it:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...