How to speed up data processing when extracting from a large cell array?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Dyuman Joshi
2023-9-19
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
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!