MATLAB: Determine total length/size of a structure array with fields as structure arrays

不问归期 提交于 2019-12-05 17:16:15

This will work if every structure array data has the same fields and are row vectors (i.e. 1-by-N):

allData = [s.data];               %# Concatenate all data arrays into one
timestamp = [allData.timestamp];  %# Collect all the time stamps

If the data structure arrays are column vectors (i.e. N-by-1), you need to use vertcat instead:

allData = vertcat(s.data);        %# Concatenate all data arrays into one
timestamp = [allData.timestamp];  %# Collect all the time stamps

The above solutions work due to the fact that accessing a single field of a structure array returns a comma-separated list.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!