2010-12-30 9 views

Antwort

3

Einige der häufigsten sind in this MathWorks Technical Note erläutert.

+0

Vielen Dank! Ich vermutete, dass es von der offiziellen Seite so sein sollte, aber ich wusste nicht, wo es sein sollte ... – Peterstone

+0

Schön! Ich kannte das nicht. – Jonas

3

Hier sind einige der häufigsten Fehler:

%# create two arrays, one 3-by-3, one 4-by-4 (see 'help magic' for details about them) 
>> m3 = magic(3); 
>> m4 = magic(4); 

%# matrix multiplication error. Arrays must be X-by-Y and Y-by-Z 
>> m3*m4 
??? Error using ==> mtimes 
Inner matrix dimensions must agree. 

%# cannot multiply (add, subtract...) element-wise if not the same number of elements 
>> m3.*m4 
??? Error using ==> times 
Matrix dimensions must agree. 

%# m3 is 3-by-3, and thus has only 9 elements. There is no element #10 
>> m3(10) 
??? Index exceeds matrix dimensions. 

%# there is also no element #-1 
>> m3(-1) 
??? Index exceeds matrix dimensions. 

%# can only index with integers or logicals 
>> m3(2.2) 
??? Subscript indices must either be real positive integers or logicals. 

%# m5 has not been defined yet. This is the "probably a typo"-error 
>> m5(3) 
??? Undefined function or method 'm5' for input arguments of type 'double'. 

%# Cannot assign the elements of m4 to m3, because they don't have the same number of elements. 
%# m3(:) = m4(1:9) would work. 
>> m3(:) = m4(:) 
??? In an assignment A(:) = B, the number of elements in A and B 
must be the same 

Darüber hinaus, wenn es eine kryptische Fehler ist es in der Regel innerhalb eines Matlab eingebauten Funktion, weil Sie die Funktion falsch (zB mit einer Zelle genannt Array, wo es Strings erwartet, oder mit NaN, wo es endliche Vektoren erwartet.

Verwandte Themen