Figure set color error

Hi,
I get this very annoying error which just blocks me :
figure; set(gcf,'color','w'); ??? Index exceeds matrix dimensions.
wtf ?! Setting color works when I start Matlab. Then, when I try doing it in a script. I get this error. And this error then just happens all the time even if I just type the above in the command window with a new figure.
I am running Matlab 2011a on MacOSX 10.7.3. Please help, it is urgent. I need my data to be plotted properly for an upcoming conference and this stupid error just blocks my whole progress.
Thanks a lot for any help.

 채택된 답변

Andreas Goser
Andreas Goser 2012년 5월 21일

0 개 추천

When it is urgent - call Technical Support and don't rely on the community ;-)
But my guess is that you use variable or function that conflicts with your code line. Imagine what happens if gcf is a 1x2 variable.

추가 답변 (3개)

Jan
Jan 2012년 5월 21일

1 개 추천

I think it is the scalar variable called "set", which stops your program from working correctly. See:
which set -all
It is recommended not to shadow built-in function by variables to avoid such unexpected problems. But such problems appear frequently in this forum, such that accidental shadowing cannot be called "unexpected" actually. Therefore I'd even dare to claim, that the forum is powerful enough to fix this problem.
Another idea is the standard procedure:
dbstop if error
Then Matlab stops when the error occurs. Then "whos" reveal the current variables and splitting the command into parts and run them in the command line reveals the underlying problem soon.
Yves
Yves 2012년 5월 21일

0 개 추천

Hi Andreas, Thanks for this super quick reply. I have checked for this by just typing gcf between the 2 above commands to see what it looks like, the error even happens if gcf = 2. I think it is somehow memory related. In a smaller Workspace it does not happen using the exact same script. The error message is just completely misleading. I will check with my larger dataset again later. Thanks!

댓글 수: 1

Andreas Goser
Andreas Goser 2012년 5월 21일
GCF overlay was just an example. This also can be FIGURE, SET and sometimes even stuff that is used in called functiions.

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

Yves
Yves 2012년 5월 21일

0 개 추천

Thanks to both of you. Sorry, Andreas I did not get your point when I first read your post. But yes, very stupid error of mine, there is a variable named "set", because I sorted my data in sets of images....
And of course both of you are right, one should not give function names to variables. In the rush, I did not pay attention and because of the large Workspace I did not see the lower end of variables. Beginners mistake.
Thanks again.
PS : Sorry, Jan I could only accept one answer. Andreas was first ;)

댓글 수: 1

Jan
Jan 2012년 5월 21일
I'm happy if your problem is solved. And I think, this experience will help you to avoid this mistake multiple times in the future.
If you like to, you can vote for an answer also.

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

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2012년 5월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by