5.0

5.0 | 3 ratings Rate this file 192 downloads (last 30 days) File Size: 2.39 KB File ID: #17818

All Permutations of integers with sum criteria

by Bruno Luong

 

30 Nov 2007 (Updated 16 Sep 2009)

Code covered by BSD License  

All Pernutations of integers with sum criteria

Download Now | Watch this File

File Information
Description

This function provides all combinations of integer vector that must verify a criteria on the sum.

Supported criteria is
sum(v) == L1
sum(v) <= L1
sum(v) < L1

MATLAB release MATLAB 7.1.0 (R14SP3)
Zip File Content  
Other Files allVL1.m,
license.txt
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
13 Dec 2007 John D'Errico

A slick solution to this problem, that uses an elegant recursive code for its work.

Good help, error checks, defaults for arguments where they apply. One minor flaw that I'll hope the author fixes. There is no H1 line. An H1 line is the first line of help. It should be a descriptive line that the function lookfor keys on, including all reasonable keywords that you might search on.

Lookfor is useful when you need to find this function in a year. Will you remember the name "allVL1" next year? No, probably not. But lookfor will find this function for you, if you supply an H1 line.

05 Mar 2008 Greg von Winckel

Great stuff. I used your work in my code that I just submitted here, but forgot to give credit. I will fix that as soon as I can modify the entry. Thanks for your help!

21 Sep 2009 Ben Petschel

Nice program. Users might also be interested in a looped solution using the function "nextwhile" in the NextVector toolbox <pre class="link">http://www.mathworks.com/matlabcentral/fileexchange/24757&lt;/pre&gt;. If the entire matrix of combinations is needed then Bruno's version is faster (because row concatenation is slow) otherwise the looped solution is faster.

Please login to add a comment or rating.
Updates
01 May 2008

Add H1 line as suggested by John D'Errico

18 May 2009

Possibility to get the number of permutations to check feasibility

16 Sep 2009

Correct a bug when the number of solutions is inquired

Tag Activity for this File
Tag Applied By Date/Time
permutation l1 polynomial multivirables order Bruno Luong 22 Oct 2008 09:37:21
permutation Bruno Luong 18 May 2009 07:34:14
polynomial Bruno Luong 18 May 2009 07:34:15
l1 Bruno Luong 18 May 2009 07:34:15
multivirables Bruno Luong 18 May 2009 07:34:15
order Bruno Luong 18 May 2009 07:34:15
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com