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일

1 개 추천

idx = hsl.clusternya==3 ; % logical indexing
T(idx,:)

댓글 수: 7

Fabyola
Fabyola 2021년 6월 11일
편집: Fabyola 2021년 6월 11일
i've tried and it said
Undefined operator '==' for input arguments of type 'cell'.
Stephen23
Stephen23 2021년 6월 11일
편집: Stephen23 2021년 6월 11일
@Fabyola: why is clusternya a cell array if it apparently only contains scalar numerics?
If its data are all scalar numeric, then you should fix the creation/importing of this data, so that any numeric data is stored in numeric arrays, not in cell arrays. Then your data processing (like this question) will be much easier.
Fabyola
Fabyola 2021년 6월 11일
i used cell array for the enitre table because of the other columns contains a string, on those kelurahan's variable
Walter Roberson
Walter Roberson 2021년 6월 11일
The whole point of table objects is that each variable can be a different datatype. The kelurahan variable is the only one that needs to be cell (or string() object, or categorical object)
Stephen23
Stephen23 2021년 6월 11일
@Fabyola: only kelurahan should be a string array or cell array of charactor vectors. All of the other data should be numeric vectors/arrays, otherwise you will make processing your numeric data very difficult.
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일

2 개 추천

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()

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

질문:

2021년 6월 11일

댓글:

2023년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by