Matlab GNU倍频程尺寸不匹配错误?
我在GNU八度音阶上出错Matlab GNU倍频程尺寸不匹配错误?,matlab,octave,gnu,Matlab,Octave,Gnu,我在GNU八度音阶上出错 error: sim_encryption: A(I,J,...) = X: dimensions mismatch error: called from sim_encryption at line 11 column 13 Line 11 is " s( 1 , : ) = mod( s + k , 2 ) ;" . 当我搜索错误时,据说问题是关于矩阵的,但矩阵看起来并没有什么不同。那么问题是什么呢 ph = '3243f6a8885a30
error: sim_encryption: A(I,J,...) = X: dimensions mismatch
error: called from
sim_encryption at line 11 column 13
Line 11 is " s( 1 , : ) = mod( s + k , 2 ) ;" .
当我搜索错误时,据说问题是关于矩阵的,但矩阵看起来并没有什么不同。那么问题是什么呢
ph = '3243f6a8885a308d313198a2e0370734' ;
kh = '2b7e151628aed2a6abf7158809cf4f3c' ;
k = zeros( 11 , 128 ) ;
r = zeros( 11 , 8 ) ;
s = zeros( 11 , 128 ) ;
s( 1 , : ) = hex_to_bin( ph ) ;
k( 1 , : ) = hex_to_bin( kh ) ;
r( 1 , : ) = [ 0 0 0 0 0 0 0 1 ] ;
s( 1 , : ) = mod( s + k , 2 ) ;
for i = 1 : 10 ,
i ;
[ k( i+1 , : ) , r( i+1 , : ) ] = key_schedule( k( i , : ) , r( i , : ) ) ;
s( i+1 , : ) = mod( k( i+1 , : ) + aes_round( s( i , : ) , i ) , 2 ) ;
kh = bin_to_hex( k(i+1,:) , 32 ) ;
sh = bin_to_hex( s(i+1,:) , 32 ) ;
end
ch = bin_to_hex( s(11,:) , 32 )
由于s和k的大小均为11 x 128,因此
mods+k,2也是11 x 128,您试图覆盖s1,也就是1 x 128s1的问题是:=hex_to_bin ph?不,用s1表示:=mod s+k,2;我认为modx,y是1x1矩阵,s1,:是1xn矩阵,这就是为什么存在不匹配的原因。@AlperKucukkomurler当传递数组输入时,mod为什么会返回标量?啊,对不起,我没有注意到……是的,你是对的。我更改代码s1:=mods1:+k1:,2;非常感谢你。