MATLAB: How to plot histogramme

MATLABplotvector

How can I plot histograme of a vector with four values independant?
v=[1; 2;0;1]

Best Answer

If those values describe the bar height, you could use bar(___,width) and specify the width of the bars as 1 to resemble a histogram.
v=[1; 2;0;1];
bar(v,1) % figure shown below
Alternatively, you can use histogram('BinEdges',edges,'BinCounts',counts) which specifies the bin edges.
histogram('BinEdges',.5 : 1 : 4.5,'BinCounts',v)