Creating a table with every possible combination of rows from other tables
조회 수: 17 (최근 30일)
이전 댓글 표시
Hello,
I currently have multiple tables with different sets of information in. I am wanting to create one large table that includes all the possible combinations of all of these sets of data in. For example, it would create a table by taking the first row of the first table and then iterating through all of the remaining tables until all possible combinations had been displayed in a table. Is there a way to do this?
Many thanks for your help,
Josh
댓글 수: 2
the cyclist
2021년 3월 20일
What you want to do is not clear to me. Showing a small example of the input and output would be very helpful in understanding what you mean.
답변 (1개)
Gargi Patil
2021년 3월 24일
If my understanding is right, you have multiple tables with each row corresponding to the various test scores for a student. The desired output should present an exhaustive combination such that each combination has all the tests listed and a particular student is chosen for each test.
A possible workaround to the problem could be to display the scores of the students in the output for each test instead of the student names. You can then map the scores to the corresponding students.
The above can be achieved by extracting the scores of all the students for a particular test as a vector. You can then run the following code:
%Let test1, test2, test3, test4 be vectors containing test scores
[W, X, Y, Z] = ndgrid( test1, test2, test3, test4);
out = [W(:), X(:), Y(:), Z(:)];
Each row of the output matrix ‘out’ will contain a possible combination with the score of the student displayed for the test. The combined score can be calculated summing across the values of the row.
You can refer to the further link for more information:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Outputs에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!