The following code works OK, switching y limit in Fig3_axes.
plot_into3=handles.Fig3_axes; ylim_menu = uicontextmenu; hcb1 = 'set(gco, ''YLimMode'',''auto'')'; hcb2 = 'set(gco, ''Ylim'',[0,1])'; uimenu(ylim_menu, 'Label', 'auto', 'Callback', hcb1); uimenu(ylim_menu, 'Label', 'manual', 'Callback', hcb2); set(plot_into3,'uicontextmenu',ylim_menu);
However, when I try to replace [0,1] by a variable
Fig3yLim=[0,1]; hcb2 = 'set(gco, ''Ylim'',Fig3yLim)';
I am getting an error:
Undefined function or variable 'Fig3yLim'.Error while evaluating uimenu Callback
How can I use the variable?
Best Answer