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 ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by