MATLAB: Error with number replication in a cell array

replicate numbers cell array

Hi guys, mx is a 100×61 cell array. I want to replicate the numbers of all cells in the cell array with the following formula but i get the following error:
n=61
for f = 1:n
for k=1:length(mx)
myCells{k,f} = [mx{k,f} ((kron([mx{k,f}], ones(4,1))))];
end
end
Error using horzcat Dimensions of matrices being concatenated are not consistent.
I tried many things to correct it but it didnt help. can anyone help.

Best Answer

This is possibly what you want:
for ...
for ...
mycells{k, f} = [mx{k,f}; kron(mk{k, f}, ones(4, 1))];
end
Note that the bounds of your loops don't look right. You could just replace the loops with a cellfun
mycells = cellfun(@(m) [m; kron(m, ones(4, 1)], mx, 'UniformOutput', false);