I have a constant 2D double matrix mat1
. I also have a 2D cell array mat2
where every cell contains a 2D or 3D double matrix. These double matrices have the same number of rows and columns as mat1
. I need to dot multiply (.*) mat1
with every slice of each double matrix within mat2
. The result needs to be another cell array results
with the same size as mat2
, whereby the contatining double matrices must equal the double matrices of mat2
in terms of size.
Here's my code to generate mat1
and mat2
for illustrating purposes. I am struggling at the point where the multiplication should take place.
rowCells = 5;
colCells = 3;
rowTimeSeries = 300;
colTimeSeries = 5;
slices = [1;10];
% Create 2D double matrix
mat1 = rand(rowTimeSeries, colTimeSeries);
% Create 2D cell matrix comprisiong 2D and/or 3D double matrices
mat2 = cell(rowCells,colCells);
for c = 1:colCells
for r = 1:rowCells
slice = randsample(slices, 1, true);
mat2{r,c} = rand(rowTimeSeries, colTimeSeries, slice);
end
end
% Multiply (.*) mat1 with mat2 (every slice)
results = cell(rowCells,colCells);
for c = 1:colCells
for r = 1:rowCells
results{r,c} = ... % I am struggling here!!!
end
end