data extract from array or vector
3 次查看(过去 30 天)
显示 更早的评论
how to extract rows from single column array using loop? example I have 96X1, I need extract like (1,13,25...end), (2,14,26,....end), (3,15,27,....end)
0 个评论
回答(1 个)
Voss
2023-1-28
data = rand(96,1); % 96-by-1 column vector
for ii = 1:12
subset = data(ii:12:end);
% do something with subset
end
Or you can reshape the column vector into a matrix:
all_subsets = reshape(data,12,[]).';
Then each column of all_subsets is one of the subsets you got in the loop.
2 个评论
Voss
2023-1-28
You're welcome! Any questions, let me know; otherwise, please Accept this Answer. Thanks!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!