i have 30 nba teams stored as categorical and i am trying to sort each one into either west or east conference.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 29 Dez. 2022
Create one categorical for West, and one for East, and combine:
W = categorical({'Kings', 'Flames'})
W = 1×2 categorical array
Kings Flames
E = categorical({'Bruins', 'Canadiens'})
E = 1×2 categorical array
Bruins Canadiens
B = [W,E]
B = 1×4 categorical array
Kings Flames Bruins Canadiens
Now you can
top2 = {'Bruins', 'Kings'}
top2 = 1×2 cell array
{'Bruins'} {'Kings'}
ismember(top2, categories(W))
ans = 1×2 logical array
0 1
ismember(top2, categories(E))
ans = 1×2 logical array
1 0

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by