Reputation: 33864
I have a struct, which has 2 fields: time
and pose
. I have multiple instances of this struct composed in an array, so an example of this is:
poses(1)
-time = 1
-pose = (doesn't Matter)
poses(2)
-time = 2
-pose = (doesn't Matter)
poses(3)
-time = 3
-pose = (doesn't Matter)
...
Now when I print this:
poses.time
I get this:
ans =
1
ans =
2
ans =
3
How can I take that output and put it into a vector?
Upvotes: 11
Views: 10012
Reputation: 6015
For cases that the field values are vectors (of same size) and you need the result in a matrix form:
posmat = cell2mat({poses.pose}');
That returns each pose
vector in a different row of posmat
.
Upvotes: 2
Reputation: 11168
Use brackets:
timevec=[poses.time];
tricky matlab, I know I know, you'll just have to remember this one if you're working with structs ;)
Upvotes: 18