I am trying to concatenate several columns of one cell array with several columns of another cell array.
I have A = 6xn, where n can be any number between 1&9.
I have B = 6xm,where m can be any number between 1&9
I need to create a cell array C = 6x1
For example:
A =
472x2 double 471x2 double 488x2 double 496x2 double 494x2 double 495x2 double
472x2 double 471x2 double 488x2 double 496x2 double 494x2 double 495x2 double
472x2 double 471x2 double 488x2 double 496x2 double 494x2 double 495x2 double
472x2 double 471x2 double 488x2 double 496x2 double 494x2 double 495x2 double
472x2 double 471x2 double 488x2 double 496x2 double 494x2 double 495x2 double
472x2 double 471x2 double 488x2 double 496x2 double 494x2 double 495x2 double
B=
460x2 double 509x2 double 503x2 double 503x2 double 488x2 double 490x2 double 488x2 double 503x2 double 518x2 double
460x2 double 509x2 double 503x2 double 503x2 double 488x2 double 490x2 double 488x2 double 503x2 double 518x2 double
460x2 double 509x2 double 503x2 double 503x2 double 488x2 double 490x2 double 488x2 double 503x2 double 518x2 double
460x2 double 509x2 double 503x2 double 503x2 double 488x2 double 490x2 double 488x2 double 503x2 double 518x2 double
460x2 double 509x2 double 503x2 double 503x2 double 488x2 double 490x2 double 488x2 double 503x2 double 518x2 double
460x2 double 509x2 double 503x2 double 503x2 double 488x2 double 490x2 double 488x2 double 503x2 double 518x2 double
The result, for each row, of concatenating all columns of A and the first 4 columns of B will be:
C=
4891x2 double
4891x2 double
4891x2 double
4891x2 double
4891x2 double
4891x2 double
I can concatenate all columns of A for each row with:
for i=1:6
C{i,1}=cat(1, A{i,:});
end
I want to avoid several for loops and the creation of intermediate variables, so I tried:
for i=1:6
C{i,1}=cat(1, A{i,:}, B(i,[1:num_extra_trials_w]));end
for i=1:6
C{i,1}=cat(1, A{i,:}, cat(1,B(i,[1:num_extra_trials_w])));end
for i=1:6
C{i,1}=cat(1, A{i,:}, {cat(1,B(i,[1:num_extra_trials_w]))});end
But none are creating a 6x1 cell array with 4891x2 double in each. What would be the proper syntax?
Thank you for your help!