-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathconvert3DCellArrayToMat.m
More file actions
34 lines (25 loc) · 875 Bytes
/
convert3DCellArrayToMat.m
File metadata and controls
34 lines (25 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function [dataMat,subMatIndices] = convert3DCellArrayToMat(cellArray)
% Allocates a matrix as output container and pastes the cellArray in it
% Input format has to be [numFrames x featureDim]
numVids = size(cellArray,1);
if nargin < 2
totalNumFrames = 0;
for i = 1:numVids
totalNumFrames = totalNumFrames + size(cellArray{i},1);
end
end
frameCounter = 0;
dim2 = size(cellArray{1},2);
dim3 = size(cellArray{1},3);
dataMat = zeros(totalNumFrames,dim2,dim3);
% dataMat = zeros(totalNumFrames,dim2-1,dim3);
subMatIndices = zeros(numVids,2);
for i =1:numVids
if (mod(i,1000) == 0)
disp(num2str(i));
end
numFrames = size(cellArray{i},1);
subMatIndices(i,:) = [frameCounter+1 numFrames];
dataMat(frameCounter+1:frameCounter + numFrames,:,:) = cellArray{i};
frameCounter = frameCounter + numFrames;
end