MATLAB Answers

Rare examples of confusing error messages

16 views (last 30 days)
Jan on 23 Apr 2012
Usually Matlab creates very helpful error messages, e.g.:
??? Subscript indices must either be real positive integers or logicals.
It does not require much experience to identify the source of this error rapidly. (Finding a solution is completely different story!) Compared with e.g. the messages of famous operating systems or the GCC compiler, the high quality of these messages is extremely helpful.
Do you know counter-examples? Some misleading or irrelevant messages created by Matlab?
James Muchechetere
James Muchechetere on 23 Aug 2019
Yes. Got this message in r2017a:
Error using CPFSKModulator/parenReference
When the BitInput property is set to true, inputs must have be double or logical.

Sign in to comment.

Accepted Answer

Andreas Goser
Andreas Goser on 24 Apr 2012
My all-time favourite is
Caught unexpected exception of unknown type.

Sign in to comment.

More Answers (8)

Jan on 24 Apr 2012
In Matlab5.3 (R11), but not in modern releases:
% First time:
reshape(1, [-1 -1])
??? Error using ==> reshape
Don't do this again!.
% Second time:
reshape(1, [-1 -2])
??? Error using ==> reshape
Cleve says you should be doing something more useful.
% Third time:
reshape(1, [-1 -3])
??? Error using ==> reshape
Seriously, size argument cannot be negative.
Image Analyst
Image Analyst on 26 Apr 2012
Too bad. Why can't people have some fun?

Sign in to comment.

Daniel Shub
Daniel Shub on 23 Apr 2012
Definitely on the irrelevant side, but luckily it was taken care of pretty quickly. I think it might be the first bug I reported to TMW.
Basically someone at TMW left a debugging message in the serial port object callback so that it would always rethrow the last warning.

Oleg Komarov
Oleg Komarov on 23 Apr 2012
The guilty one:
Undefined function 'foo' for input arguments of type 'char'.
No inputs:
Undefined function or variable 'foo'.
Use as variable OR function?
clear foo
Undefined function or variable 'foo'.
The two error messages considered together make you think that the first one is simply not properly behaving BECAUSE of the input.
However, most commonly it's the case of "undefined function" which is already implemented!
I suggest to suppress the first one and throw always the second message.
Jan on 24 Apr 2012
It would be helpful to get one of these messages:
>> Undefined function 'foo' for input arguments of type 'char'
>> But there are these foo() functions for other inputs: ...
>> Undefined function 'foo' for input arguments of type 'char'
>> There is no other foo() function also.

Sign in to comment.

Daniel Shub
Daniel Shub on 23 Apr 2012
Another unhelpful aspect of error handling in MATLAB is if you catch an error in a callback and then rethrow the error, you lose the stack information.

Jan on 17 Jan 2017
Error using load
Number of columns on line 1 of ASCII file
must be the same as previous lines.
Most likely the text format does not match the one written by save -ascii, but where can I find the previous line of line 1?

Adam on 17 Jan 2017
was one I got the other day. Not sure what I had done to get it though! I especially like the one word per line formatting!
Adam on 18 Jan 2017
It's definitely something deep down as I got it again yesterday when I tried to open a file that I had moved and was actually not on my path any more. I hit Ctrl C or pause or something and ended up with that message. It isn't something in my own code or 3rd party code that I have though so not sure what its source is!

Sign in to comment.

Jan on 20 Jun 2017
Edited: Jan on 22 Aug 2017
A = rand(1393120, 1);
xlswrite('Test.xlsx', A)
Error using xlswrite (line 219)
The specified data range is invalid or too large to write to the
specified file format. Try writing to an XLSX file and use Excel A1
notation for the range argument, for example, A1:D4.
Since Excel 2007 only up to 1'048'576 rows (2^20) are accepted. Then "too large" is fine and Matlab has all information to detect this. Suggesting an XLSX file and "A1:A1393120" will not solve the problem.

Community Treasure Hunt

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

Start Hunting!