|
On Mar 9, 11:55 am, "Ioannis Botonakis"
<i.botonakis_withoutth...@googlemail.com> wrote:
> Hallo!
>
> Can you please tell how to get a histogram with the following edges:
>
> edges = [0 200 350 500 800 ceil(max(data))];
>
> It seems that the hist or the histc functions do not work.
>
> Sincerely
> I. Botonakis
-----------------------------------------------------------------------------------------------
Funny, histc() seemed to work for me. You might need to call tech
support or issue the command "which -all histc" to see if you've
redefined histc. Because with my code it works fine:
% Generate some sample data.
data = 2000*rand(1,100000);
edges = [0 200 350 500 800 ceil(max(data))];
% Take the histogram.
counts = histc(data, edges)
bar(counts);
set(gca,'XGrid','off','YGrid','on');
% Enlarge figure to full screen.
set(gcf, 'Position', get(0,'Screensize'));
% Label axes.
ylabel('Counts', 'FontSize', fontSize);
xlabel('Bins', 'FontSize', fontSize);
% Label the bins (tick marks).
for bin = 1: length(edges)-1
x_labels{bin} = sprintf('%d - %d', ...
edges(bin), edges(bin+1));
end
x_labels{bin+1} = ' ';
set(gca,'XTickLabel', x_labels, 'FontSize', fontSize);
|