how to find specific value in a table?

108 ビュー (過去 30 日間)
Fabyola
Fabyola 2021 年 6 月 11 日
コメント済み: piston_pim_offset 2023 年 12 月 4 日
if i have hsl table like this, so how to find row that have value = 3 in column 1 (which is 'clusternya')?
i've tried to use
ind1= strfind(hsl.clusternya,'3')
but the error said like this:
Error using strfind
Cell must be a cell array of character vectors.

採用された回答

KSSV
KSSV 2021 年 6 月 11 日
編集済み: KSSV 2021 年 6 月 11 日
idx = hsl.clusternya==3 ; % logical indexing
T(idx,:)
  7 件のコメント
Fabyola
Fabyola 2021 年 6 月 11 日
aah i see, okaay i'll try them. thanks for your advice, all.
piston_pim_offset
piston_pim_offset 2023 年 12 月 4 日
What if we have UITable in app designer @KSSV?

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 6 月 11 日
ind1 = find(hsl.clusterya == 3)
But you should probably be considering, for example
mask1 = hsl.clusterya == 3;
dist = sqrt(hsl.v1(mask1).^2 + hsl.v2(mask1).^2)
because using logical masks is generally faster than using find()

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by