Extracting all possible vectors from a big vector
Mostrar comentarios más antiguos
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 comentarios
Image Analyst
el 12 de Jun. de 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
el 12 de Jun. de 2021
Respuesta aceptada
Más respuestas (1)
SALAH ALRABEEI
el 12 de Jun. de 2021
Editada: SALAH ALRABEEI
el 12 de Jun. de 2021
0 votos
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!