Finding all integer vectors between two vector bounds
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mathieu
le 20 Déc 2018
Réponse apportée : James Tursa
le 20 Déc 2018
I would like to find all the integers vectors between two vector bounds. For instance, suppose that
lb = [0;1;0;1]
ub = [2;1;0;1]
Then the function would return
[0;1;0;1]
[1;1;0;1]
[2;1;0;1]
I need this in arbitrary dimenions n, I plan on evaluate a function that takes each of these vectors as argument.
Thanks!
0 commentaires
Réponse acceptée
James Tursa
le 20 Déc 2018
You can use the FEX submission allcomb( ) by Jos for this:
c = arrayfun(@(a,b)a:b,lb,ub,'uni',false);
result = allcomb(c{:});
The vectors you want are the rows of the result. You can find allcomb here:
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Stair Plots dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!