Course:GEOB503/Error Log

From UBC Wiki

GEOB 503: Error Messages and Their Causes

This page is intended as a general programming reference. Once a student comes up with an error message and figures out what causes that error message, they should post their findings here for others to refer to.

Errors in Matlab

Error using ==> mtimes
Inner matrix dimensions must agree.

This error occurs in Matlab when trying to multiply two matrices together using < * >. Matrix multiplication requires the the number of columns in one of the vectors is the same as the number of rows. If you have one row vector and one column vector, then the outcome of a successful matrix multiplication will be a single number (often not what we are really after). if you simply want to multiple the first element of matrix one by the first element of matrix two, then the second element of one times the second element of two, then the third element by the third element, simply use < .* > instead of < * > between your matrices (e.g. < C = A.*B > instead of < C= A*B >).


Subscripted assignment dimension mismatch.

This message is generated when you try to add more data to a row or column in an existing matrix than can fit in that row. For example, if X is a 2 by 2 matrix, and you try to replace the first column by typing< X(:,1) = [1 2 3] >, or you try to replace the first row by typing < X(1,:) = [1 2 3] >, you will get this message.

Errors in R