i have 2 (n,1) cell arrays. both of contain 1x8 cell arrays inside each cell.
i need to:
1) combine first element of first array each element of second array
2) combine second element of first array each element of second array , on.
and store them inside third cell array :
{ {f_array1} {s_array1}; {f_array1} {s_array2}; {f_arrayn} {s_array2}; {f_arraym} {s_arraym};
i have tried loops one:
for l = 1:u(1,1) m = 1:v(1,1) a{l} = {e{l},f{m}}; end end
but in combines 1 element 1 element.
any sugestions?
i use repmat
on cell arrays expand them out , concatenate them.
f_array = {{{1} {1} {1} {1} {1} {1} {1} {1}},... {{2} {2} {2} {2} {2} {2} {2} {2}},... {{3} {3} {3} {3} {3} {3} {3} {3}}}; s_array = {{{4} {4} {4} {4} {4} {4} {4} {4}},... {{5} {5} {5} {5} {5} {5} {5} {5}},... {{6} {6} {6} {6} {6} {6} {6} {6}}}; f_expanded = repmat(f_array(:), numel(s_array), 1); s_expanded = repmat(s_array(:), 1, numel(f_array)).'; output = num2cell(cat(2, f_expanded(:), s_expanded(:)), 2);
Comments
Post a Comment