Thank you Brent. One otherway to make it even faster is to use C++ via MEX.

29 Aug 2013

INTERSECTALL
Given set of sets, produce all possible intersections for each set or all sets at once.
Author: Mehmet Suzen

@Alle Meije,

Thanks for the feedback. I have added one more utility, called INTERSECTALLSET. It does what you need. Also, I've updated the description, hoping that now it is clear what INTERSECTALL produces.

09 Nov 2012

INTERSECTALL
Given set of sets, produce all possible intersections for each set or all sets at once.
Author: Mehmet Suzen

Just uploaded a new version with the following example, hope it helps:

There is a much faster option available (I am using R2014a) using accumarray. For my applications the code below was 100 times faster.

function [histw histv] = histwv(v, w, min, max, bins)
%Inputs:
%vv - values
%ww - weights
%minV - minimum value
%maxV - max value
%bins - number of bins (inclusive)

Hi! Just a comment: If you want a weighted histogram in more than one dimension, you can use the submission histcn in file exchange. Just use the option histcn(...,'AccumData', weights); The result will not be 100% the same as the one obtained with this function, since the bin edges are calculated differently.

Thanks for the feedback. I have added one more utility, called INTERSECTALLSET. It does what you need. Also, I've updated the description, hoping that now it is clear what INTERSECTALL produces.

There is a much faster option available (I am using R2014a) using accumarray. For my applications the code below was 100 times faster.
function [histw histv] = histwv(v, w, min, max, bins)
%Inputs:
%vv - values
%ww - weights
%minV - minimum value
%maxV - max value
%bins - number of bins (inclusive)
%Outputs:
%histw - wieghted histogram
%histv (optional) - histogram of values
delta = (max-min)/(bins-1);
subs = round((v-min)/delta)+1;
histv = accumarray(subs,1,[bins,1]);
histw = accumarray(subs,w,[bins,1]);
end

Hi! Just a comment: If you want a weighted histogram in more than one dimension, you can use the submission histcn in file exchange. Just use the option histcn(...,'AccumData', weights); The result will not be 100% the same as the one obtained with this function, since the bin edges are calculated differently.

@Alle Meije,
Thanks for the feedback. I have added one more utility, called INTERSECTALLSET. It does what you need. Also, I've updated the description, hoping that now it is clear what INTERSECTALL produces.

Comment only