Matlab Easter Egg - Funny Reshape (R11)

The reshape function only works with positive size arguments. However, if you try it with negative size arguments, you do not get your typical boring MATLAB error message. You even get three different answers !

First try:
» reshape(1, [-1 -1])
??? Error using ==> reshape
Don't do this again!.

Comment: MATLAB seems shocked you request such an operation !

Second try:
» reshape(1, [-1 -2])
??? Error using ==> reshape
Cleve says you should be doing something more useful.

Comment: Nice advice from Cleve Moler, cofounder of the Mathworks.

Third try and following:
» reshape(1, [-1 -3])
??? Error using ==> reshape
Seriously, size argument cannot be negative.

Comment: OK, let's be serious and get back to work now.

User Rating:
6.8
  6.8/10 with 80 votes
Contributed By: Fanfan on 10-31-2001
Reviewed By: Webmaster
Special Requirements: Tested in MATLAB R11
Please correct this Egg if you see errors.

Pictures and Videos

Reshape easter egg dans MATLAB  par Aurélien QUEFFURUST
Reshape easter egg dans MATLAB par Aurélien QUEFFURUST

Do you have another one? Send us a picture or video of this Egg!

Comments

myth writes:
Does not work for release R2006b (7.3.0.267).
6 of 11 people found this comment helpful. Did you? Yes No
JWPanther writes:
This works for MATLAB 6.1 also.
3 of 9 people found this comment helpful. Did you? Yes No


Register - Privacy Policy - About Us - Contact Us