To compare two variables in a bar graph in MATLAB, you can follow the below steps:
34 chars3 lines
bar
function:53 chars5 lines
Here, we are plotting two bar graphs, one for variable x
and the other for y
. 'b'
and 'r'
are used to set the colors of two bars. The hold on
command ensures that both bar graphs are plotted in the same figure.
You will now have a bar graph comparing the two variables.
gistlibby LogSnag