필터 지우기
필터 지우기

Working with tables that are within a timetable

조회 수: 1 (최근 30일)
Lisbon
Lisbon 2020년 1월 2일
댓글: J. Alex Lee 2020년 1월 4일
Hi there,
I have a 10x1 timetable. Each row in that timetable is another table with the list of positions (rows), and their properties (columns) for those dates.
I need to work with that data, for example, create another timetable with only the positions for which one of the properties is equal to X.
But I'm not able to tacke the tables.
The code I had was: D = TT.Issue{:,Column10==FIX};
Is not working, nor: D = TT.Issue.Column10=='FIX';
Can someone help please?

답변 (1개)

J. Alex Lee
J. Alex Lee 2020년 1월 3일
편집: J. Alex Lee 2020년 1월 3일
I would first flatten the table, especially if you will be making many queries. Something like
DataCell = cell(height(TT),1);
For i=1:height(TT)
t = TT{i,"Issue"};
T.Time = repmat(TT.Time(i), height(TT),1)
DataCell{i} = t;
end
Data = vertcat(DataCell{:})
Then query as a usual table
RowMask = Data.Column10=='FIX'
NewTable = Data(RowMask,:)
The rowmask line may fail if column10 is not of type categorical
  댓글 수: 4
Lisbon
Lisbon 2020년 1월 3일
Error on RowMask = Data.Column10=='FIX':
Dot indexing is not supported for variables of this type.
J. Alex Lee
J. Alex Lee 2020년 1월 4일
Yes, you might consider typing your columm10 as a categorical if it makes sense.
Data.Column10 = categorical(Data.Column10)

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by