create a histogram with edges in matlab

To create a histogram with specified bin edges in Matlab, you can use the histogram function along with the edges parameter. Below is an example code snippet:

main.m
% Generate some example data
data = randn(1000,1);

% Define bin edges
edges = [-3 -2 -1 0 1 2 3];

% Create and plot histogram
histogram(data,edges);
151 chars
9 lines

In the above code, we first generate some example data using the randn function. Next, we define the bin edges we want to use for the histogram in the edges variable. Finally, we create and plot the histogram using the histogram function and passing in the data and edges as arguments.

This will create a histogram with the specified bin edges. If you want to customize the appearance of the histogram further, you can use additional parameters of the histogram function such as FaceColor, EdgeColor, and Normalization.

gistlibby LogSnag