我在创建一个矩阵的函数时发生了错误,程序如下:
L1=[A B C D E F G H I J K L M...
N O P Q R S T U V W X Y Z];
L2=[one two three four five...
six seven eight nine zero];
character=[L1 L2];
templates=mat2cell(character,42,[24 24 24 24 24 24 24 ...
24 24 24 24 24 24 24 ...
24 24 24 24 24 24 24 ...
24 24 24 24 24 24 24 ...
24 24 24 24 24 24 24 24]);
出错原因:
Warning: Concatenation with dominant (left-most) integer class may overflow other operands on conversion to return class.
> In CREATE at 44
??? Error using ==> horzcat
CAT arguments dimensions are not consistent.
Error in ==> CREATE at 44
L1=[A B C D E F G H I J K L M...
好像是什么数据溢出的? 搞了好久都搞不定,请高手指点迷津。 谢谢
按照二楼的所说的看看出错时character的大小
>> a=[1,2,3];
错误分法
>> mat2cell(a,1,[2 2])
??? Error using ==> mat2cell at 116
Input arguments, D1 through D2, must sum to each dimension of the input matrix size, [1 3].
正确分法
>> mat2cell(a,1,[2 1])