Inserting more rows between already existing rows of a structure
15 次查看(过去 30 天)
显示 更早的评论
Hello,
I am trying to extract data of interest from a time data series in the form of episodes.
Y = accelerometer data
t = time data
pks & locs = location and amplitude of peaks of interest
I already have sections of data which could be data of interest into episodes in the structure:
n = amount of episodes
grp_pks(n).Y = Y(1,i_str:i_end);
grp_pks(n).t = t(1,i_str:i_end);
grp_pks(n).i = [i_str, i_end];
grp_pks(n).pks = pks;
grp_pks(n).locs = locs;
After analysing the peaks further, I want to devide the episodes when peaks are further apart then 2 sec and delete episodes with > 5 peaks.
Therefore, I would need to be able to insert extra n into the structure, e.g. having grp_pks(3) devided into grp_pks(3), grp_pks(4), grp_pks(5), ... without overwriting the grp_pks(4), grp_pks(5), ... . Is that possible? with Matrixes I would just do:
mtx_pks = [mtx_pks(1:2,:); pks; mtx_pks(4:end,:)];
but I am not sure how to tansfere that onto a structure.
Thank you
0 个评论
采纳的回答
Stephen23
2019-5-21
编辑:Stephen23
2019-5-21
"but I am not sure how to tansfere that onto a structure. "
In exactly the same way. All MATLAB arrays use the same indexing concept, so if you can do it with a numeric array then you can do it with a structure array. You can concatenate, use indexing to select subsets, or to assign to specific values, reshape, etc., just as with every other type of array.
Important to keep in mind is that when using indexing into a structure the structure being allocated must have exactly the same fields.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!