extracting data from struct(structure within a structure)

6 ビュー (過去 30 日間)
Cside
Cside 2019 年 8 月 21 日
コメント済み: Cside 2019 年 8 月 21 日
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

採用された回答

Matt J
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
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?
Cside
Cside 2019 年 8 月 21 日
yes it does, thank you so much!! :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by