MATLAB: How to solve this error

error

g=cat(4,A1,C,len,A1);
This command gives no error for
C=>> C
C(:,:,1,1) =
Columns 1 through 6
'42' '83' '1e' 'c2' '21' '77'
Columns 7 through 12
'74' '24' '4b' '72' '21' 'b7'
Columns 13 through 16
'84' 'd0' 'd4' '9c'
C(:,:,1,2) =
Columns 1 through 6
'e3' 'aa' '21' '2f' '2c' '02'
Columns 7 through 12
'a4' 'e0' '35' 'c1' '7e' '23'
Columns 13 through 16
'29' 'ac' 'a1' '2e'
C(:,:,1,3) =
Columns 1 through 6
'21' 'd5' '14' 'b2' '54' '66'
Columns 7 through 12
'93' '1c' '7d' '8f' '6a' '5a'
Columns 13 through 16
'ac' '84' 'aa' '05'
C(:,:,1,4) =
Columns 1 through 6
'1b' 'a3' '0b' '39' '6a' '0a'
Columns 7 through 12
'ac' '97' '3d' '58' 'e0' '91'
Columns 13 through 16
'47' '3f' '59' '85'
But when I change the C to this input:
C=>> Cipher
Cipher(:,:,1,1) =
'9' '1'
'7' '8'
'6' '4'
'5' '1'
'2' '7'
'9' '8'
'F' '8'
'A' '9'
'B' 'C'
'6' '2'
'D' '9'
'D' 'D'
'4' '8'
'0' 'B'
'7' 'D'
'4' '4'
Cipher(:,:,1,2) =
'0' '4'
'3' 'A'
'E' '3'
'5' '5'
'B' 'F'
'A' '3'
'C' '5'
'3' '2'
'3' '7'
'D' 'B'
'3' 'C'
'F' '3'
'E' 'F'
'4' '9'
'F' 'D'
'E' '1'
Cipher(:,:,1,3) =
'A' '4'
'0' '8'
'2' '5'
'0' '7'
'B' 'E'
'5' '8'
'C' '7'
'C' 'B'
'9' '8'
'E' '3'
'4' '8'
'D' 'C'
'C' '3'
'9' '6'
'A' '9'
'6' 'F'
Cipher(:,:,1,4) =
'A' '3'
'3' '0'
'7' '2'
'A' 'A'
'8' 'E'
'3' '3'
'A' '0'
'E' '7'
'1' 'C'
'E' 'B'
'E' '5'
'D' 'B'
'A' 'C'
'7' '5'
'8' 'B'
'7' '7'
I get an error stating:
Error using cat
Dimensions of matrices being concatenated are
not consistent.
Error in tryyy (line 154)
g=cat(4,A1,Cipher,len,A1);
What must be done?
A1- 1x16 cell
Cipher- 4d cell
C-4d cell
len-1x16 cell
Can sombody help me?

Best Answer

C(:,:,1,4) and others are 1 x 16
Cipher(:,:,1,4) and others are 16 x 2
At the very least you need to transpose the items to 2 x 16. There might still be a problem compared to 1 x 16 but you should get further.