Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Error using RESHAPE but I'm not using reshape

Asked by Rednar on 22 Jul 2013

When executing one of my functions I'm getting:

Error using reshape To RESHAPE the number of elements must not change.

But my function doesn't even use reshape, any ideas of what is going on here? I mean, what other MATLAB function am I maybe using incorrectly that could be throwing this error?

5 Comments

Cedric Wannaz on 22 Jul 2013

Actually with JIT not being used in debugging sessions, I already observed differences in behavior, but not to the extent of using different functions internally.

Rednar on 23 Jul 2013

I didn't change a thing, I have no reason for lying. Maybe the bug was related with the fact that I was using the matlabcontrol java API and calling that MATLAB function a lot during the execution of a genetic algorithm. MATLAB was throwing me that error only sometimes and sometimes it worked fine. After several runs of my Java program the error stopped appearing in MATLAB. I really could not figure out what happened back there. Anyways, thanks a lot for the answers, I'll use the debugger in the future for sure if something goes wrong (even though usually I don't have to because MATLAB points me at the line where the error happened, only this time it wasn't).

Cedric Wannaz on 23 Jul 2013

I don't think that Jan wanted to suggest that you were lying, but sometimes when we debug code, we check things out by e.g. commenting a few lines at different/random places, and we end up being unable of reproducing the bug when we want to ;-)

Rednar

Tags

Products

1 Answer

Answer by Sean de Wolski on 22 Jul 2013
Accepted answer
dbstop if error

Then run your code. This will stop with the debugger on the offending line and you will be able to see what is happening.

1 Comment

per isakson on 23 Jul 2013

Make it a habit to use the debugger. It's good. Here are some links on debugging in Matlab

Sean de Wolski

Contact us