Find all possible combinations of string array
이전 댓글 표시
Hi,
i have a struct that contains cells of different dimensions. I need a way to find all possible combinations of all cells.
The cells containing string variable e.g: matrix(1).elements = {'500A', '600B', '700C',''}, matrix(2).elements = {'100AC', '300D', '200CA','60G'}, matrix(3).elements = {'100BC', '300DF', '200AA','60GR'}...(some cells have less variables and for this reason i have " at the last element of matrix(1))
The total number of combinations in the example above is: 4*4*4=64
The results that i would like is a mat like: 1) 500A,100AC, 100BC,
2) 500A,100AC, 300DF
3) 500A,100AC, 200AA...
I tried allcomb function but it doesn't work
Any idea on that?
Thanks in advance
채택된 답변
추가 답변 (1개)
David Hill
2021년 12월 7일
편집: David Hill
2021년 12월 7일
You could get all possible combinations and then index into your struct.
[idxa,idxb,idxc]=ndgrid(1:5,1:3,1:7);
카테고리
도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!