Best Way to Convert Data in a Structure to an Array
조회 수: 1 (최근 30일)
이전 댓글 표시
I am doing the following to convert data in a structure to an array. It seems a little clunky. Is there a better way?
a(1).data = [1 2];
a(2).data = [3 4];
a(3).data = [5 6];
a(4).data = [7 8];
data2 = cell2mat({a.data}');
댓글 수: 2
Bob Thompson
2021년 2월 26일
data2 = vertcat(a(:).data);
I don't have a good way to make your definition of a.data any better.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!