Splitting an array up
2 次查看(过去 30 天)
显示 更早的评论
Hello,
i have a 64x92690 EEG dataset that i want to split into 40 parts of 64x2048.
As 2048 times 40 isen't 92690, i've been having trouble with the reshape function.
C = num2cell(reshape(x, 2048, 64, 1);
The excess amount of data i dont really care about.
Any suggestions would help
Thanks in advaced!
采纳的回答
更多回答(2 个)
Stephen23
2020-10-19
Just use mat2cell, no need for reshape:
>> M = rand(64,92690); % fake data
>> N = 2048;
>> S = size(M);
>> V = repmat(N,1,fix(S(2)/N));
>> C = mat2cell(M,S(1),[V,mod(S(2),N)]);
0 个评论
Rik
2020-10-19
编辑:Rik
2020-10-19
You can modify the row indices you feed to mat2cell:
data=rand(64,92690);%generate random data
div=2048;
c=div*ones(1,ceil(size(data,2)/div));
c(end)=c(end)-(sum(c)-size(data,2));%trim last block
split=mat2cell(data,size(data,1),c);
%split is a 1x46 cell array, with the last cell containing fewer elements if the data doesn't fit
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 EEG/MEG/ECoG 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!