% given already binned data: % a is the value, and b is the count % create a logarithmically binned histogram using the optional argument % logbase for the width of the bins function [midpoints,histsum] =logbinfromlinbin(a,b,logbase) if (nargin < 3) logbase = 2 end if (logbase <=1 ) disp('warning: logbase should be > 1. exiting...'); return; end [a1,ia] = sort(a); a2 = b(ia); max2 = ceil(log(max(a1)+1)/log(logbase)); tmp = 0:max2; x = (logbase).^(tmp); midpoints = ceil((x(2:length(x))-x(1:(length(x)-1))-1)/2)+x(1:(length(x)-1)); disp(midpoints); disp(x); i = 1; j = 1; histsum = zeros(size(midpoints)); while (i <= length(a1)) if (a1(i) < x(j+1)) histsum(j) = histsum(j) + a2(i); else j = j + 1; histsum(j) = histsum(j) + a2(i); end i = i+1; end histsum = histsum./(x(2:length(x))-x(1:(length(x)-1)));