Filtering elements of a cell array and indexing

조회 수: 4 (최근 30일)
Waqas Syed
Waqas Syed 2016년 9월 4일
댓글: Waqas Syed 2016년 9월 4일
Hi,
I have attached a mat file. In the file there are two variables; "groups" and "chan_group_p1".
I would like to obtain a vector with indices of locations of the cell array "groups" on which the content of variable "chan_group_p1" are present.
I tried to do something like followng but it does not work: id= find(groups==chan_group_p1);
My understanding of different kinds of variables in matlab is not so good. Let me know how I should do this task.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2016년 9월 4일
idx = find(cellfun(@(x)strcmp(x,chan_group_p1),groups));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by