creating combinations for different data type

i have two inputs which has 2 differnt data types and i wanted to create combinations.
The first Column1 has input1 = 8, Age
The Secind Column 2 has input2 = 20, gender
And i want to create a combinations something like this
8,Age
20,Age
8,gender
20,gender

댓글 수: 1

Create a Cell array or a Table and use nchoosek to make combinations and indexing to implement it.

댓글을 달려면 로그인하십시오.

답변 (1개)

Steven Lord
Steven Lord 2023년 7월 20일
If you're using release R2023a or later use the combinations function.
T = combinations([8, 20], ["Age", "Gender"])
T = 4×2 table
Var1 Var2 ____ ________ 8 "Age" 8 "Gender" 20 "Age" 20 "Gender"

댓글 수: 1

PA
PA 2023년 7월 20일
Thanks! But I am using 2019 so i cannot use the combinations function . Is there any other possible way apart from this?

댓글을 달려면 로그인하십시오.

카테고리

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

제품

릴리스

R2019a

태그

질문:

PA
2023년 7월 20일

댓글:

PA
2023년 7월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by