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

 採用された回答

Walter Roberson
Walter Roberson 2022 年 12 月 29 日

0 投票

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

質問済み:

2022 年 12 月 29 日

回答済み:

2022 年 12 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by