How to solve this error?

1 回表示 (過去 30 日間)
Darsana P M
Darsana P M 2018 年 3 月 14 日
コメント済み: Darsana P M 2018 年 3 月 15 日
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?

採用された回答

Walter Roberson
Walter Roberson 2018 年 3 月 14 日
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.
  1 件のコメント
Darsana P M
Darsana P M 2018 年 3 月 15 日
thank you sir

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2018 年 3 月 14 日
A1,Cipher,len, and A1 must all be the same data class and size to concatenate them. They can't be a mixture of sizes like you have. You can't concatenate a 1-D array to a 4-D array like you tried.
  3 件のコメント
Image Analyst
Image Analyst 2018 年 3 月 14 日
Cell arrays are just a special kind of array (See the FAQ), but they behave like regular arrays in many ways, like concatenating. If you don't believe me, just try to do the same thing with ordinary double arrays and see what happens:
A1 = ones(1, 16); %- 1x16 cell
Cipher = ones(16,16,16,16); %- 4d cell
C = ones(16,16,16,16); %-4d cell
len = ones(1, 16); %-1x16 cell
g=cat(4,A1,Cipher,len,A1)
You see -- the same error. Also, see Walter's answer below.
Darsana P M
Darsana P M 2018 年 3 月 15 日
thank you Sir

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEncryption / Cryptography についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by