Logical Indexing for entire Table

조회 수: 141 (최근 30일)
Adam Attarian
Adam Attarian 2018년 10월 24일
댓글: Leone Campos 2023년 1월 3일
Essentially, I am trying to do (pseudo code):
T=table(data); % T contains many columns of doubles, date times, and is otherwise numeric.
m = T.field == condition; % Logical indexing based on some field
T=T(m); % implicit application of mask m to each column in T.
Of course, the last line isn't supported by Matlab and returns an error:
Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more
subscripts) is not supported. Use a row subscript and a variable subscript.
Is there a way to essentially downsample an entire table based on a logical index mask? It is conceivable that table T has a large (100s) of columns, and manually indexing into each column could be too time consuming.
  댓글 수: 1
Ahmed Radwan
Ahmed Radwan 2019년 11월 21일
Hi, I tried your solution, but it didn't work..
for dp=1:length(DataPoint)
data(dp,:)=adeInfo;
end
I get this error:
Right hand side of an assignment into a table must be another table or a cell array.
adeInfo is not a table. it is as follows, as shown in MATLAB: "A singleton class"

댓글을 달려면 로그인하십시오.

채택된 답변

Adam Attarian
Adam Attarian 2018년 10월 24일
The solution is simple, and I'm ashamed I didn't see it earlier:
T=T(m,:);
  댓글 수: 1
Leone Campos
Leone Campos 2023년 1월 3일
You shouldn't be ashamed of yourself, you helped me :D

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Monika Lingvay
Monika Lingvay 2019년 11월 11일
편집: Monika Lingvay 2019년 11월 11일
Thank you, I was looking for the same question and answer!

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by