"uicontrol" is not working well in MATLAB2015b

1 回表示 (過去 30 日間)
Meshooo
Meshooo 2016 年 2 月 2 日
コメント済み: Meshooo 2016 年 2 月 8 日
Dear all, I couldn't run this code in MATLAB2015b, but it was working well before
uicontrol('Style', 'pushbutton', 'String', 'SAVE',...
'Position', [20 20 50 20],...
'Callback', ...
@yourCallback); % what do you want to do?
function yourCallback(ObjH, EventData)
I = getimage;
setappdata(0, 'I', I);
resXGui; %the name of the GUI where to transfer
clc
Error:Function with duplicate name "yourCallback" cannot be defined.
Does anyone knows how to make it work again for MATLAB2015b?
Regards, Meshoo

回答 (1 件)

Jan
Jan 2016 年 2 月 2 日
編集済み: Jan 2016 年 2 月 2 日
There is another function called "yourCallback" inside the M-file. Rename the function - I suggest to use meaningful names, because this reduces the chance for such collisions.
  4 件のコメント
Walter Roberson
Walter Roberson 2016 年 2 月 3 日
Provided that B_GUI is the figure handle of the target figure (or a uipanel or uitab on the target figure)
I = imread('cameraman.tif');
newfig = figure();
newax = axes('Parent', newfig);
Ih = imshow(newax, I);
cb = @(hObject, eventdata) imshow(axes('Parent', B_GUI), get(Ih, 'CData'))
bh = uicontrol('style', 'push', 'Parent', newfig, 'Callback', cb);
Meshooo
Meshooo 2016 年 2 月 8 日
OK, thank you very much.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by