フィルターのクリア

Update static text for Guide Gui from main matlab function?

5 ビュー (過去 30 日間)
Ioan Alexandru
Ioan Alexandru 2013 年 3 月 13 日
コメント済み: Farley Postgate 2018 年 6 月 15 日
Dear Community,
I've been going round and round the Matlab documentation and available threads for some time now and I couldn't manage to find a solution to this: Let's say I have function A.m and GUI.m. A.m has one big function with lots of things in it. GUI.m is the Guide Gui Matlab file which contains all the functions for CreateFcn, Callback, etc. When I run A.m from GUI.m (suppose I call A.m when I press a button from GUI), function A.m obviously will start doing stuff. However, I want to be able to change, for example, the text in a static text box of the GUI.m from within A.m while it is running. Unfortunately, I wasn't able to find a solution to this. Most threads revolve around calling an external function from within , let's say, a callback gui function.
I would really appreciate your support. Thank you very much.
Regards,
Alex
P.S.: is there a way of doing it in a simple was as?:
%line in A.m
GUI(set(handle.statictext,'String','EUREKA'));
I understand that the GUI functions are "nested" so inaccessible to the A.m but I was hopping that there would be a way of calling the handles in something similar to this. The expectation is fairly simple: I want to change the content of a GUI static text box from any external function I wish: even command line.
Thank you
  1 件のコメント
Farley Postgate
Farley Postgate 2018 年 6 月 15 日
You just have to send back whatever variable you are manipulating in the main function to the GUI and the code you have there works fine. I just tried it. Or make the variable global.

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

採用された回答

Jan
Jan 2013 年 3 月 14 日
編集済み: Jan 2013 年 3 月 14 日
The question is not clear:
  1. ... suppose I call A.m when I press a button from GUI ...
  2. ... Most threads revolve around calling an external function from within , let's say, a callback gui function.
This means, that most thread concern exactly your problem. Then they should help you already.
One of the many solutions to share data between a GUI and any other function:
function buttonCallback(hObject, EventData, handles)
% This is the callback of the button, which starts the external function.
GuiHandle = ancestor(hObject, 'figure');
A(rand(1,2), rand(3,4), GuiHandle); % Or how ever it is called
And the function header of the external function:
function output = A(in1, in2, GuiHandle)
handles = guidata(GuiHandle);
set(handles.statictext, 'String', 'Written from external function!');

その他の回答 (1 件)

Ioan Alexandru
Ioan Alexandru 2013 年 3 月 14 日
Hello Simon,
Thank you for your quick reply. Indeed, this is what I was looking for. I'm new to Guide Gui since I only used the normal gui interface until now; now I have to understand the guide gui data management. In my case I have an A(GuiHandles) function with no outputs and I call it from the callback of a pushbutton. Again, thanks!
Regards, Alex
  1 件のコメント
Jan
Jan 2013 年 3 月 14 日
編集済み: Jan 2013 年 3 月 14 日
I'm glad that I could help.
Please post comments as comments. If several answers are posted, the order of answers can change and your message looses the connection.

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

カテゴリ

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