Split or extract a part of the data in a cell
조회 수: 44 (최근 30일)
이전 댓글 표시
Starting from a cell called "data" sized 17x1, containing each one 1x1487040 double
i would be able to extract the first 1/4 of the content from the 9th to the 14th cells obtaining a matrix of double.
The problem arises because i usually have huge lengths for the double numbers in the cell, so that if i first use cell2mat (with the intention of splitting the array after) an out of memory error comes up.
It is possible to split a cell of double without cell2mat?
댓글 수: 0
답변 (2개)
Guillaume
2016년 2월 25일
A = cell2mat(cellfun(@(v) v(1:numel(v)/4), data.data(9:14), 'UniformOutput', false))
댓글 수: 0
Arnab Sen
2016년 2월 25일
Hi greta,
My understanding is that you would like to extract a part of cell from a cell array. You can directly access the cell of the cell array without converting the whole cell array to matrix. As an example, if you want to extract the first 1/4th content from 9th cell, you can do something link below:
>> A=data{9}(:,1:length(data{9})/4);
You can use a for loop to extract from multiple cell. Something like
>>for I=9:14
A[I]=data{I}(:,1:length(data{I})/4);
end
Regards,
Arnab
댓글 수: 1
Guillaume
2016년 2월 25일
The gist of the idea is there, but I'd like to point out that:
A[I]
is not valid matlab syntax. At the very least, it should be
A(I, :)
And A should be predeclared before the loop.
Secondly, since the content of the cells are all vector, 2d indexing is not required so
data{I}(:,1:length(data{I})/4)
can be simplified to
data{I}(1:numel(data{I})/4) %and numel is a lot safer than length
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!