MATLAB: Common colorbar

colorbar

Dear all,
I made a function f_colorbar.m enabling me to customize a colorbar. However, all of a sudden (& months ago it work without the error and in between I did not change anything at least to my knowledge that could cause this) I get this warning-error:
>> Error in ==> legendcolorbarlayout>layoutColorbar at 829 [width,height]=preferredColorbarSize(origc);
??? Output argument "newpos" (and maybe others) not assigned during call to "C:\Program Files\MATLAB\R2010b\toolbox\matlab\scribe\legendcolorbarlayout.m>layoutColorbar".
Error in ==> legendcolorbarlayout>doInOutLayout at 498 [newpos,corners] = layoutColorbar(location,corners,origc);
Error in ==> legendcolorbarlayout>doLayout at 441 doInOutLayout(par,fig,outlist,corner1,corner2,false);
Error in ==> legendcolorbarlayout>doParentResize at 338 doLayout(ch);
Warning: Error occurred while evaluating listener callback. > In legendcolorbarlayout>reclaimSpace at 1002 In legendcolorbarlayout at 88 In scribe.colorbar.init>changedLocation at 92 In scribe.colorbar.init>changedPos at 116 In f_colorbar at 125 >>
The 125 line says set(hcb,'position',newpos). By the way, on my other computer, having the same matlab (2010b) and the same OS (Win 7 x64) I do not encounter this issue.
Any ideas, … anything ?
Cheers
Blaz

Best Answer

Hard to say without seeing the code, but it looks like there's some condition that makes it possible for layoutColorbar to complete without newpos ever being defined -- that's the initial warning, which then leads to the error on line 125 of f_colorbar. Presumably it's a subtle bug in the logic which hasn't manifested until now.
With the Editor, you can highlight a variable and see where it shows up in that file. Maybe you can use that to trace the creation of newpos and see if there's anything that could prevent it. You could also simply try putting a breakpoint in layoutColorbar and stepping through (when running an example you know is failing).