One way is to use the histcounts command to get the counts, and then use the bar command to do the plotting (because it will do the side-by-side):
rng 'default'
data1 = randn(20,1);
data2 = randn(30,1);
data3 = randn(40,1);
data4 = randn(50,1);
edges = -4:1:4;
h1 = histcounts(data1,edges);
h2 = histcounts(data2,edges);
h3 = histcounts(data3,edges);
h4 = histcounts(data4,edges);
figure
bar(edges(1:end-1),[h1; h2; h3; h4]')
I did not take great care to properly line up the "edges" variable with the counts. There are some nuances with respect to exactly how the binning is done. I suggest reading the documentation for histcounts.