필터 지우기
필터 지우기

extracting the second column of all cells of a struct

조회 수: 3 (최근 30일)
Sahar khalili
Sahar khalili 2022년 10월 11일
댓글: Sahar khalili 2022년 10월 12일
I have a struct, x1_surf, that contains 1070 cells, each cell has 4 cells, now I want to extract the second column of the inner cells with the order.
This is x1_surf
This is the x1_surf{1,1}
now, I want to extract the second column of all inccer cells with the correct order, I mean x1_surf{1,:}{1,2}
I write a script like that:
It works correcly for some files, however for some other files, the order of the date is mixed up and they are not in the right order. Could anyone help me how I can rewise it?
  댓글 수: 1
Stephen23
Stephen23 2022년 10월 11일
You should replace all of the nested 1x4 cell arrays with TIMETABLEs or TABLEs.

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

채택된 답변

David Hill
David Hill 2022년 10월 11일
for k=1:length(x1_surf)
x2_surf{k}=x1_surf{k}{2};
end
  댓글 수: 5
David Hill
David Hill 2022년 10월 12일
I am assuming you just want just one listing of all the date-times.
load('x1_surf.mat');
x2_surf=[];
for k=1:length(x1_surf)
x2_surf=[x2_surf;x1_surf{k}{2}];
end
x2_surf(1:20)
ans = 20×1 datetime array
11-Sep-2019 13:29:00 11-Sep-2019 13:39:00 11-Sep-2019 13:49:00 11-Sep-2019 13:59:00 11-Sep-2019 14:09:00 11-Sep-2019 14:19:00 11-Sep-2019 14:29:00 11-Sep-2019 14:39:00 11-Sep-2019 14:49:00 11-Sep-2019 14:59:00 11-Sep-2019 15:09:00 11-Sep-2019 15:19:00 11-Sep-2019 15:29:00 11-Sep-2019 15:39:00 11-Sep-2019 15:49:00 11-Sep-2019 15:59:00 11-Sep-2019 16:09:00 11-Sep-2019 16:19:00 11-Sep-2019 16:29:00 11-Sep-2019 16:39:00
Sahar khalili
Sahar khalili 2022년 10월 12일
Thank you so much, it worked.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by