Rank: 702 based on 99 downloads (last 30 days) and 7 files submitted
photo

David Fass

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by David View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
01 Nov 2004 MINTERSECT -- Multiple set intersection. A generalization of INTERSECT to handle multiple inputs. Author: David Fass intersect, set, intersection, multiple 26 5
  • 5.0
5.0 | 4 ratings
03 Sep 2004 PARTPERM -- Partial random permutation of a vector Partial random permutation of a vector. Author: David Fass statistics, probability, permute, permutation, index, random 4 1
  • 5.0
5.0 | 1 rating
12 Aug 2004 CONTIGUOUS -- Start and stop indices for contiguous runs RUNS = CONTIGUOUS(A,NUM) returns the start and stop indices for contiguous runs of the elements NUM Author: David Fass run length, length, runs, run, runlength, contiguous 2 0
16 Jul 2004 IND2SUBVECT: Multiple subscript vector from linear index. A perversion of IND2SUB that returns a vector of N indices rather than N individual variables. Author: David Fass matrices, subscript, convert, linear, index, vector 15 2
16 Jul 2004 CARTPROD: Cartesian product of multiple sets Returns a matrix containing the cartesian product of multiple input sets. Author: David Fass sets, cartesian, product, permutation 25 5
  • 4.2
4.2 | 5 ratings
Comments and Ratings on David's Files View all
Updated File Comment by Comments Rating
29 Dec 2011 CARTPROD: Cartesian product of multiple sets Returns a matrix containing the cartesian product of multiple input sets. Author: David Fass Michael

I need to use the cartesian product

19 Dec 2011 MINTERSECT -- Multiple set intersection. A generalization of INTERSECT to handle multiple inputs. Author: David Fass Alexander

One small correction: at the end the line

varargout(k) = {};

should be changed to

varargout(k) = {[]};

19 Dec 2011 MINTERSECT -- Multiple set intersection. A generalization of INTERSECT to handle multiple inputs. Author: David Fass Alexander

Very useful function, thanks. Although it doesn't return indices like usual intersect.
That's actually quite easy. Here's what that function should look like. Please update your submition so other people could use it

function [runIntersect, varargout] = mintersect(varargin)
%MINTERSECT Multiple set intersection.
% MINTERSECT(A,B,C,...) when A,B,C... are vectors returns the values
% common to all A,B,C... The result will be sorted. A,B,C... can be cell
% arrays of strings.
%
% MINTERSECT repeatedly evaluates INTERSECT on successive pairs of sets,
% which may not be very efficient. For a large number of sets, this should
% probably be reimplemented using some kind of tree algorithm.
%
% MINTERSECT(A,B,'rows') when A,B,C... are matrices with the same
% number of columns returns the rows common to all A,B,C...
%
% [C,IA,IB,IC,...] = MINTERSECT(...) returns required number of indices, similar to INTERSECT
%
% See also INTERSECT

flag = 0;
if isempty(varargin),
    error('No inputs specified.')
else
    if isequal(varargin{end},'rows'),
        flag = 'rows';
        setArray = varargin(1:end-1);
    else
        setArray = varargin;
    end
end

nout = min(length(setArray),max(nargout,1)-1);
varargout = cell(nout, 1);
for k = 1:nout
    varargout(k) = {(1:length(setArray{k}))'};
end

runIntersect = setArray{1};
for i = 2:length(setArray),
    
    if isequal(flag,'rows'),
        [runIntersect, i1, i2] = intersect(runIntersect,setArray{i},'rows');
    elseif flag == 0,
        [runIntersect, i1, i2] = intersect(runIntersect,setArray{i});
    else
        error('Flag not set.')
    end
    for k = 2:min(i,nout+1)
        varargout(k-1) = {varargout{k-1}(i1)};
    end
    if k <= nout
        varargout(k) = {i2};
    end
    
    if isempty(runIntersect)
        for k = 1:nout
            varargout(k) = {};
        end
        return
    end
    
end

29 Apr 2011 IND2SUBVECT: Multiple subscript vector from linear index. A perversion of IND2SUB that returns a vector of N indices rather than N individual variables. Author: David Fass Jaap

Thanks.

28 Sep 2010 CARTPROD: Cartesian product of multiple sets Returns a matrix containing the cartesian product of multiple input sets. Author: David Fass Alipour, Mehrdad

I need to make a cartesian roduct of a vector for variable dimension but i cant find a code for this purpose. can somebody help me please?!!

Top Tags Applied by David
permutation, probability, random, statistics, index
Files Tagged by David View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
01 Nov 2004 MINTERSECT -- Multiple set intersection. A generalization of INTERSECT to handle multiple inputs. Author: David Fass intersect, set, intersection, multiple 26 5
  • 5.0
5.0 | 4 ratings
03 Sep 2004 PARTPERM -- Partial random permutation of a vector Partial random permutation of a vector. Author: David Fass statistics, probability, permute, permutation, index, random 4 1
  • 5.0
5.0 | 1 rating
12 Aug 2004 CONTIGUOUS -- Start and stop indices for contiguous runs RUNS = CONTIGUOUS(A,NUM) returns the start and stop indices for contiguous runs of the elements NUM Author: David Fass run length, length, runs, run, runlength, contiguous 2 0
16 Jul 2004 IND2SUBVECT: Multiple subscript vector from linear index. A perversion of IND2SUB that returns a vector of N indices rather than N individual variables. Author: David Fass matrices, subscript, convert, linear, index, vector 15 2
16 Jul 2004 CARTPROD: Cartesian product of multiple sets Returns a matrix containing the cartesian product of multiple input sets. Author: David Fass sets, cartesian, product, permutation 25 5
  • 4.2
4.2 | 5 ratings

Contact us at files@mathworks.com