how to find specific value in a table?

388 views (last 30 days)
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.

Accepted Answer

KSSV
KSSV on 11 Jun 2021
Edited: KSSV on 11 Jun 2021
idx = hsl.clusternya==3 ; % logical indexing
T(idx,:)
  7 Comments
Fabyola
Fabyola on 11 Jun 2021
aah i see, okaay i'll try them. thanks for your advice, all.
piston_pim_offset
piston_pim_offset on 4 Dec 2023
What if we have UITable in app designer @KSSV?

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 11 Jun 2021
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()

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!