How to sum 3D arrays in a 1x3 cell?
3 views (last 30 days)
Show older comments
Hi all,
Thanks in advance for your help. So:
I have a 1x1 cell array that consists of 3 arrays of size 1366x9x1333, 1366x9x1332, 1366x9x1332. However, these arrays were generated from a cross-correlation function with an increasing lag (from 1-3) and so the number of time points from the initial image is 3999. More specifically, if we, for example, assume a lag of 3, the cross correlation function is called and calculated the cross correlation between the 1,4,7,10... lines and then the 2,5,8,11...lines and then the 3,6,9,12....lines. I'd like to combine these three arrays along the third dimension so that we regain the original number of points (3999) and the points are returned to the order: 1,2,3,4,5,6,7,8,9...
Is there a way to do this?
0 Comments
Accepted Answer
Guillaume
on 20 Jul 2018
If I understood correctly you want to interlace the pages:
%Assuming cell array is 1x3, not 1x1 as you wrote:
numpages = sum(cellfun(@(m) size(m, 3), yourcellarray));
fullarray = zeros(size(yourcellarray{1}, 1), size(yourcellarray{1}), 2), numpages);
fullarray(:, :, 1:3:end) = yourcellarray{1};
fullarray(:, :, 2:3:end) = yourcellarray{2};
fullarray(:, :, 3:3:end) = yourcellarray{3};
would be one way.
0 Comments
More Answers (0)
See Also
Categories
Find more on Matrix Indexing 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!