How to speed up data processing when extracting from a large cell array?
2 views (last 30 days)
Show older comments
I am dealing with a large cell array (e.g., 3826341x1 cell). I would like merge the data or matrix from each cell. Using 'cell2mat' takes so much of time. Is there any alternative to cell2mat to process the data faster? Any leads will be highly appreciated. Thanks.
5 Comments
Dyuman Joshi
on 19 Sep 2023
load('array.mat')
whos
f1=@(x) cell2mat(x);
f2=@(x) vertcat(x{:});
f3=@(x) cat(1,x{:});
F1 = @()f1(alphaClusterAll);
F2 = @()f2(alphaClusterAll);
F3 = @()f3(alphaClusterAll);
fprintf('Time taken by cell2mat = %f seconds', timeit(F1))
fprintf('Time taken by vertcat = %f seconds', timeit(F2))
fprintf('Time taken by cat = %f seconds', timeit(F3))
isequal(F1(),F2(),F3())
You can try this FEX submission - Cell2Vec
Answers (0)
See Also
Categories
Find more on Logical 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!