Indexing structure array. Every first entry of an vector.
Show older comments
Hello, I have stored a lot of vectors in the fields of an structure array and i want to get every first element. s is an 1xN struct. field1 contains the vector
a = s(1:end).field1(1)
or
a = s.field1(1)
give the same error "Expected one output from a curly brace or dot indexing expression, but there were N results."
1 Comment
Stephen23
on 25 Oct 2018
"Expected one output from a curly brace or dot indexing expression, but there were N results."
Because you are generating a comma-separated list:
Accepted Answer
More Answers (1)
Walter Roberson
on 25 Oct 2018
arrayfun(@(S) S.field1(1), s)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!