creating combinations for different data type

1 Ansicht (letzte 30 Tage)
PA
PA am 20 Jul. 2023
Kommentiert: PA am 20 Jul. 2023
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 Kommentar
Dyuman Joshi
Dyuman Joshi am 20 Jul. 2023
Create a Cell array or a Table and use nchoosek to make combinations and indexing to implement it.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Steven Lord
Steven Lord am 20 Jul. 2023
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 Kommentar
PA
PA am 20 Jul. 2023
Thanks! But I am using 2019 so i cannot use the combinations function . Is there any other possible way apart from this?

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by