如何将数字转移到GUI?

12次观看(过去30天)
Meshooo
Meshooo on 3 Feb 2016
评论: Meshoooon 3 Feb 2016
亲爱的大家,
我想向图中添加一个按钮,所以我使用了这个代码
我= imread('cameraman.tif');
图,imshow(i);
UICONTROL('风格''按钮''串''SAVE'......
'Position', 20 20 5020],......
'打回来'......
@yourcallback);
现在,在按下按钮后如何在GUI的轴上向这个数字显示这个数字?
我之前使用了以下代码,但现在不在Matlab2015B中工作
UICONTROL('风格''按钮''串''SAVE'......
'Position', 20 20 5020],......
'打回来'......
@yourcallback);
functionyourCallback(ObjH, EventData)
我= getMage;
setappdata(0,'I', 一世);
Resxgui;%the name of the GUI
有没有替代方法来做到这一点?
Any help will be appreciated.
Meshoo

2评论

Geoff Hayes
Geoff Hayes on 3 Feb 2016
Meshoo - is that all the code there is to your callback? What does getimage 做(不是所示图像所示图像的句柄)?是 ResxGui. 您希望将图像传输到的不同GUI?
请查看您的所有代码(用于此回调)并评论正在发生的事情或应该发生的事情。你这么说 我之前使用了以下代码,但现在不在Matlab2015B中工作 。请澄清代码的哪个部分不起作用。讨论您观察到的内容以及您希望观察到的内容。如果正在生成任何错误,则将全部错误消息复制并粘贴到您的问题。
Meshooo
Meshooo on 3 Feb 2016
OK, I will try to make it clearer. I have a "Main_GUI" and want to transfer an image to another GUI which called resXGui. The image will open in the axes of resXGui. One of the push buttons in resXGui will import this image from axes and open it separately as a figure window and let me add lines to the image. Now after adding the lines, I want to return back the image to resXGui axes. So the following code was there such that a push button will appear in the "figure" window and made it transferred to resXGui.
功能Varargout = ResxGui(varargin)
function pushbutton1_Callback(hObject, eventdata, handles)
我= getMage;%从ResxGui获取图像
图中,imshow(我)
1- do something
2-返回resxgui,并为此使用此代码
UICONTROL('风格''按钮''串''SAVE'......
'Position', 20 20 5020],......
'打回来'......
@yourcallback);
functionyourCallback(ObjH, EventData)
我= getMage;
setappdata(0,'I', 一世);
Resxgui;%the name of the GUI
This works normally in matlab2014, but I couldn't do it in matlab2015b. Now when calling resXGui from Main_GUI, I cann't open this resXGui anymore and this error shows
错误:文件:Resxgui.m线路:442列:10
Function重复名称“yourcallback”无法定义。
Error在Main_Gui> PushButton13_Callback(第487行)
Resxgui;%阈值GUI的名称
Error在GUI_MAINFCN(第95行)
feval(varargin {:});
Errorin Main_GUI (line 42)
gui_mainfcn(gui_state,varargin {:});
Errorin matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)Main_GUI('pushbutton13_Callback',hObject,eventdata,guidata(hObject))
Errorwhile evaluating UIControl Callback
所以这就是所有人,也很谢谢你考虑。

登录评论。

答案(1)

斯大林塞缪尔
斯大林塞缪尔 on 3 Feb 2016
我= imread('cameraman.tif');
HB = UICONTROL('风格''按钮'......
'串''点击这里'......
'打回来''imshow(i)');

4 Comments

节目 1 older comment
Meshooo
Meshooo on 3 Feb 2016
假设我们有两个GUI,A_GUI和B_GUI,都有轴。让我们说我们在一个单独的数字中打开了一个图像
我= imread('cameraman.tif');
图,imshow(i);
现在如何将一个按钮附加到这个数字,这样通过单击按钮即可在B_GUI中打开映像。
Meshooo
Meshooo on 3 Feb 2016
对,我以前从该链接那里得到了这个想法,它正常工作。但在matlab2015b中它不起作用。

登录评论。

社区宝藏狩猎

找到Matlab Central中的宝藏,并发现社区如何帮助您!

Start Hunting!