How can I sort an array of structures based upon a particular field in MATLAB?

조회 수: 2 (최근 30일)
Wenyi Xiao
Wenyi Xiao 2019년 4월 20일
답변: Wenyi Xiao 2019년 4월 20일
WeChat Screenshot_20190420221641.png
I've got a eeg_data_all(cell,size = 1*35), which contains 35*3 cells maybe. I want to sort these data by the 'subid'. How can I do this?
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 4월 20일
Each eeg_data_all{P,Q} is to be sorted separately by the subid field of its struct, or all eeg_data_all(:,:) are somehow to be sorted together, considering all of the subid for all of the cells?
Is there are reason why you stored struct in cell instead of using a nonscalar struct array?

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

답변 (1개)

Wenyi Xiao
Wenyi Xiao 2019년 4월 20일
I've solved this problem by the function nestedSortStruct
eeg_data_all{1,1} = nestedSortStruct(eeg_data_all{1,1}, 'subid'); %sort by subid

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by