Extracting all possible vectors from a big vector
Afficher commentaires plus anciens
Hi guys,
İ want to expalin with an example. Let's say i have a vector [1 2 3 4] i want to extract these [1] [2] [3] [4] [1 2] [1 3] [1 4] [2 3] [2 4] [3 4] [1 2 3] [1 2 4] [1 3 4] [2 3 4] [1 2 3 4] i found a way to do that but the problem is that they are not vectors.
How can i do that?
I know that [2 3] and [3 2] are different vectors but order is not important.
v=[1 2 3 4];
b=length(v);
i=1;
while i<=b
a = uint16(v);
c = nchoosek(a,uint16(i));
disp(c)
i=i+1;
end
2 commentaires
Image Analyst
le 12 Juin 2021
Why do you want to do this? What is the use case? The number of output vectors would blow up incredibly fast for more than a length of a few. Like if you had a vector that was hundreds long, it would be impractical.
Mehmet Fatih
le 12 Juin 2021
Réponse acceptée
Plus de réponses (1)
SALAH ALRABEEI
le 12 Juin 2021
Modifié(e) : SALAH ALRABEEI
le 12 Juin 2021
0 votes
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!