That should do it:
Responses = {[1 3 2 6 4] [4 2 5]}
sizeLongest = max(cellfun(@numel, Responses));
Responses = cellfun(@(x) [x x(randi(numel(x), 1, sizeLongest - numel(x)))], Responses, 'UniformOutput', false);
First, it takes the size of the longest sequence. Then, it uses cellfun
and, for each array x
, it concatenates itself with N
random elements from itself, where N = sizeLongest - numel(x)
.
Results:
>> Responses{:}
ans =
1 3 2 6 4
ans =
4 2 5 5 2