how use GUI outputs (variables) in another .m file?

i have created a GUI (Example.fig) with two objects --> popupmenu and edit text. The user can choose a number from popupmenu and insert a number in edit text. Then in another Example_second_Mfile.m the result should be calculated. Problem: the value of variables, which i created in Example.m of GUI, is unknown by running of Example_second_Mfile.m! how can i call the value of variables in Gui with "function varargout = Example_OutputFcn(hObject, eventdata, handles)" in Example_second_Mfile.m?

回答 (2 件)

Image Analyst
Image Analyst 2014 年 12 月 24 日

0 投票

2 件のコメント

Mahdi
Mahdi 2014 年 12 月 24 日
Many Thanks for your Help! Please read my Comment to Sara!
Image Analyst
Image Analyst 2014 年 12 月 24 日
And was the suggested FAQ method of writing the stuff out to a .mat file okay for you? If not, why not? then, what about some of the other methods like getappdata()?

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

Sara
Sara 2014 年 12 月 24 日

0 投票

If you just want to calc the result once you've inputted the values, you can do:
In function pushbutton1_Calculate_Callback(hObject, eventdata, handles), add the following lines:
Result = Example_second_Mfile(Multiple,Input);
msgbox(['Result = ',num2str(Result)]) % to see the result somewhere!
and modify the Example_second_Mfile as:
function Result = Example_second_Mfile(Multiple,Input)
Result=str2double(Multiple)*(Input);
You could also add Result=str2double(Multiple)*(Input); directly into the pushbutton1_Calculate_Callback

1 件のコメント

Mahdi
Mahdi 2014 年 12 月 24 日
Many Thanks for your Help! I actually want see the variable "Result" in Example_second_Mfile and workspace. Zip data is a simple example of my main Program. I use many functions, which I defined in different M-files. With a GUI(hier Example)
1- I want to get inputs (such as variables Input,Multiple) and use them in two different long M-files with many functions.
2- In the last M-file I plot results an want to show them in axes-Object of GUI(hier Example).
3- Furthermore i would like show some result as String in List-Object of GUI
Note: With Pushbottun1_Calculate I get just Inputs. Drawing and listing of results in GUI should be happened without activated Button.

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

カテゴリ

ヘルプ センター および File ExchangeEnvironment and Settings についてさらに検索

質問済み:

2014 年 12 月 24 日

コメント済み:

2014 年 12 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by