Logical Indexing for entire Table

118 ビュー (過去 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 Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by