将结构体数组的字段提取到新数组 [英] Extract field of struct array to new array
本文介绍了将结构体数组的字段提取到新数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个结构体,它有 2 个字段:time
和 pose
.我在一个数组中组合了这个结构的多个实例,所以一个例子是:
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)
...
现在当我打印这个时:
poses.time
我明白了:
ans =
1
ans =
2
ans =
3
如何获取该输出并将其放入向量中?
How can I take that output and put it into a vector?
推荐答案
使用方括号:
timevec=[poses.time];
棘手的 matlab,我知道我知道,如果你使用结构体,你只需要记住这个 ;)
tricky matlab, I know I know, you'll just have to remember this one if you're working with structs ;)
这篇关于将结构体数组的字段提取到新数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文