View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Integer partitions

Be the first to rate this file! 6 Downloads (last 30 days) File Size: 1.74 KB File ID: #33616 Version: 1.3

Integer partitions



04 Nov 2011 (Updated )

Finds all partitions of a set containing homogenous elements, also called integer partitions.

| Watch this File

File Information

This is similar to submission "24185-partitions" in the exchange, but with the set containing identical elements. The partitioning is a also a way of writing the input n as a sum of positive integers.

An optional argument s can be supplied to output a subset of partitions with number of parts less than or equal to s.

The number of ways of partitioning is according to the sequence

Example 1: intpartition(4) gives {[1 1 1 1],[1 1 2],[1 3],[2 2],4}
Example 2: intpartition(10,2) gives {[3,7],[4,6],[5,5],10}

Required Products MATLAB
MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
04 Nov 2011 1.1

corrected description

02 Dec 2013 1.3

--Added optional parameter s to specify maximum size of the partitions.
--Updated to more efficient code (~5x speed), as an unintended consequence, the ordering of partitions in the output cell is changed from the older version.

Contact us