필터 지우기
필터 지우기

How to extract sequences from a table?

조회 수: 3 (최근 30일)
James McBrearty
James McBrearty 2023년 8월 22일
댓글: James McBrearty 2023년 8월 22일
Hi All,
I am adapting the example by Mathworks, Sequence Classification using Deep Learning,, to work with my own problem.
I have the raw data coming in as a table, and I'm wondering is there a way to split this up into sequences, based on the values in one column, rather than an arbitrary number of rows down?
My table looks like this:
What I would like to do is to convert this to a cellarray, of various double arrays (from this picture above it will be x cells each with 2*y double arrays, however, the real table has a few more columns, so it's just an extension of this).
Many thanks,
James
  댓글 수: 4
the cyclist
the cyclist 2023년 8월 22일
Can you upload the data, or a small representative sample? You can use the paper clip icon in the INSERT section of the toolbar.
James McBrearty
James McBrearty 2023년 8월 22일
So, FCTable is attached.
What I would like is a cell array, where each cell element corresponds to a specific date (I don't need the date), and the contents of each cell would be the double array for each date.
Thanks

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

채택된 답변

Matt J
Matt J 2023년 8월 22일
편집: Matt J 2023년 8월 22일
Calling your table T,
out = splitapply(@(x){x} , T{:,[1:10,12:end]},findgroups(T.tradeDate))
  댓글 수: 6
Dyuman Joshi
Dyuman Joshi 2023년 8월 22일
"Was there something wrong with the format of the dates?"
The format hid additional information of the datetime values.
The dates might look identical, but the values for hour, minute and seconds were different for the same day. You can check that by using hms.
So, to make the data uniform, all the dates have been shifted to the start of the respective days i.e. 00:00:00
James McBrearty
James McBrearty 2023년 8월 22일
Thanks for this - I did convert the dateformat to 'dd/mm/uuuu', and I was hoping that would change them all to be uniform. At least now I know how to use dateshift in the future. Again, thanks so much.

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

추가 답변 (1개)

Matt J
Matt J 2023년 8월 22일
편집: Matt J 2023년 8월 22일
Another option, using varfun:
load FCTable
T=FCTable;
T.tradeDate=dateshift(FCTable.tradeDate,'start','day') ;
out = varfun(@(x) x, T,'Grouping', 'tradeDate','Output','cell')
out = 51×2 cell array
{46×1 double} {46×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double} {48×1 double}
  댓글 수: 1
James McBrearty
James McBrearty 2023년 8월 22일
That is a great answer too, but the other one is preferred, having a X times 1 cell array.
Thanks

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

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by