I'm using a code to pass values between guis. The first time it worked flawlessly, but the second time it neither gave me the output nor an error. Please help!

2 次查看(过去 30 天)
This is the code I used. I found this answer submitted by Geoff Hayes in another similar question. The handle visibilty has been changed to on and the tags of my figures have been changed to their respective names. What am i doing wrong?
function pushbutton1_Callback(hObject, eventdata, handles)
% get the handle of Gui1
h = findobj('Tag','Gui1');
% if exists (not empty)
if ~isempty(h)
% get handles and other user-defined data associated to Gui1
g1data = guidata(h);
% maybe you want to set the text in Gui2 with that from Gui1
set(handles.text1,'String',get(g1data.edit1,'String'));
% maybe you want to get some data that was saved to the Gui1 app
x = getappdata(h,'x');
end
  6 个评论
Geoff Hayes
Geoff Hayes 2016-3-19
编辑:Geoff Hayes 2016-3-19
Preethi - when you try to get the values from openingpagedemo, is this GUI still available (i.e. visible to the user) or have you closed it? If it has been closed, then you will not be able to obtain the length and width from it.
Preethi Thomas
Preethi Thomas 2016-3-19
编辑:Preethi Thomas 2016-4-7
Geoff, Yes I was closing it when I moved to page1. I never realised that page1 was never shut which was why it worked. Thank you!!! Now it works perfectly. :)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by