extracting data from struct(structure within a structure)
조회 수: 4 (최근 30일)
이전 댓글 표시
I have a struct dataset (trials), with 1x1 struct data set in them. The 1x1 struct data sets (under target) contain 3 fields (timestamp, row & column), and I need to shortlist them by row & column (both), into a new matrix. I tried inputing A = [(trials(1).target,'row')] but was returned with "expected one output from a curly brace or dot indexing expression, but there were 100 results"
That is my intention, to have those 100 results expressed in a new vector like so
A = 4
3
4
.......
May I know how do I correct this? Thank youu
댓글 수: 0
채택된 답변
Matt J
2019년 8월 21일
편집: Matt J
2019년 8월 21일
This may be what you want,
targets=[trials.target];
rows=vertcat(targets.row)
but it is not very clear from your post how the struct is organized. Best is to attach it in a .mat file so that forum readers can study it.
댓글 수: 3
Matt J
2019년 8월 21일
Yes, I can see it, but as far as I can tell the code I posted works fine. Did you try it?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!