Extract a series of values every n row of a matrix
3 次查看(过去 30 天)
显示 更早的评论
Hello, I have a matrix with the following dimensions 154353x3.
I would need to extract 2180 rows every 2580 rows (that means that I 2180 rows that I need to analyze, then 399 rows I do not need to analyze, then another 2180 rows I need to analyze and so on).
How is the most effective way to extract only the segments I have to analyze?
Thank you for your help
Silvia
2 个评论
采纳的回答
DGM
2022-6-14
Consider the small example:
% a small 100x3 test array
A = repmat((1:100).',[1 3])
% parameters
blocksize = 10;
rowstokeep = 7;
% reshape and truncate
A = reshape(permute(A,[1 3 2]),blocksize,[],3);
A = permute(A(1:rowstokeep,:,:),[1 3 2])
The blocks are now arranged along dim3, excess rows are omitted.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!