Choosing data based on names

Example if I have a table called data
Type Test 1
A 23
A 12
A 97
A 72
B 12
B 55
C 22
C 98
C 76
and I want to find the max and min of Type A only. Is there anyway to call Type A without hardcoding data(1,:4)

回答 (1 件)

Guillaume
Guillaume 2019 年 6 月 16 日
編集済み: Guillaume 2019 年 6 月 16 日

1 投票

Of course, you don't need to hardcode anything.
If you really just want A:
[minval, maxval] = bounds(data.Test1(data.Type == 'A')) %The exact type and name of your table variables is unclear. Adapt as needed
However, you could obtain the max and min of all types at once. This may be more useful:
groupsummary(data, 'Type', {'max', 'min'})

カテゴリ

ヘルプ センター および File ExchangeTables についてさらに検索

タグ

質問済み:

2019 年 6 月 15 日

編集済み:

2019 年 6 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by