I need help preallocating an array of position vectors
1 view (last 30 days)
Show older comments
Alexander Watkins
on 21 May 2021
Commented: Alexander Watkins
on 21 May 2021
Creating an array that stores the position vectors of circles detected in each frame of a video, how would i go about preallocating posvec?
posvec = [];
for frame_no = 1 : stack_size(4)
framecropped = frame_stack(:,:,:,frame_no);
imshow(framecropped);
[pos,rad] = imfindcircles(framecropped,[20 100]);
viscircles(pos,rad);
drawnow
posvec = [posvec; pos];
end
0 Comments
Accepted Answer
Stephen23
on 21 May 2021
Use a cell array:
tmpout = cell(1,stack_size(4))
for frame_no = 1:stack_size(4)
..
tmpout{frame_no} = pos;
end
matrix = vertcat(tmpout{:}); % optional
3 Comments
More Answers (0)
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!