Why am I getting an error when trying to linear index into my table?
>> load patients
>> T = table(Gender,Smoker,Height,Weight);
>> T(:,4)(T.Smoker==1)
Error: ()-indexing must appear last in an index expression.

 채택된 답변

MathWorks Support Team
MathWorks Support Team 2018년 9월 17일

0 개 추천

The syntax being used is trying to index into a table that has already been indexed into. Instead, index only once to get the desired behavior:
>> T(T.Smoker==1, 4)
Alternatively, this can be broken up into two lines of code:
>> temp = T(:,4);
>> temp(T.Smoker==1,:)

추가 답변 (0개)

카테고리

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

제품

릴리스

R2018a

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by