Hi Guys,
I want to combine 2 matrix & get all the possible combinations
the example is
I have matrix A & B
A = [2;4;6]
B = [1;3;5]
I want to generate all matrix C Combinations
C=[2 1 ; 2 3 ; 2 5 ; 4 1 ; 4 3 ; 4 5 ; 6 1 ; 6 3 ; 6 5]
And is there any matlab function to generate it ? Because in the future maybe I not only want to combine 2 matrix.
thanks

 채택된 답변

Bruno Luong
Bruno Luong 2018년 11월 29일
편집: Bruno Luong 2018년 11월 29일

0 개 추천

A = [2;4;6]
B = [1;3;5]
[AA,BB] = meshgrid(A,B);
C = [AA(:),BB(:)]
ans =
2 1
2 3
2 5
4 1
4 3
4 5
6 1
6 3
6 5

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2018년 11월 29일

댓글:

2018년 11월 29일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by