MATLAB: Putting the data inside the correct x values in hist plot

histxaxis

Hello,
I use hist plot. Let's say that my data is y=[3,5] and I want to make a histogram between x=1:6. I do the following.
y=[3,5]; x=1:6 hist(y,x)
This gives me two vertical bars. One bar is right above 3 and the other bar is right above 5. I want the first one between 2 and 4, and the second one between 5 and 6. Can you help me with this?
Thank you,

Best Answer

y=[3,5]; x=1:6; hist(y+0.5,x+0.5)