필터 지우기
필터 지우기

generate index for included subjects

조회 수: 1 (최근 30일)
Peter P
Peter P 2019년 7월 25일
편집: Andrei Bobrov 2019년 7월 25일
I am trying to generate an index to exclude some subjects, so far I tried:
temp.ids = 101:130
excl = {'126' '127'};
% generate index
incl = true(size(temp.ids));
for i = 1:length(excl)
% compare strings
TF = strcmp(excl{i},temp.ids);
% set excluded subjects to 0
incl(TF==1)=0;
end
When I try using:
age = temp.age(incl);
the variable 'age' still includes all 30 subjects, however it should only show the included, i.e., 28. Any suggestions? Thanks in advance.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2019년 7월 25일
편집: Andrei Bobrov 2019년 7월 25일
temp.ids = 101:130;
excl = 126:127;
incl = ~ismember(temp.ids,excl);
age = temp.age(incl);

추가 답변 (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