Error using RESHAPE but I'm not using reshape

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

Rednar
Rednar 2013년 7월 22일
It stopped giving me the error and I didn't change anything. It was really weird, I just deleted a file that uses reshape but that it has nothing to do with the function I'm running and it's not even in the same folder. I don't know what happened but it's fine now.
Jan
Jan 2013년 7월 22일
Trust me Rednar, you did change not even not anything, but exactly the cause of the error. Matlab is 100% deterministic and you can be sure, that there was a reshape() in your code. The debugger Sean has suggested would have revealed where the problem occurs.
Cedric
Cedric 2013년 7월 22일
편집: Cedric 2013년 7월 22일
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
Rednar 2013년 7월 23일
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
Cedric 2013년 7월 23일
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 ;-)

댓글을 달려면 로그인하십시오.

 채택된 답변

Sean de Wolski
Sean de Wolski 2013년 7월 22일

1 개 추천

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

per isakson
per isakson 2013년 7월 23일
Make it a habit to use the debugger. It's good. Here are some links on debugging in Matlab

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

태그

Community Treasure Hunt

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

Start Hunting!

Translated by