Matlab GUI Executing a Script with inputs

10 ビュー (過去 30 日間)
MJU
MJU 2016 年 10 月 7 日
コメント済み: MJU 2016 年 10 月 12 日
Hey guys,
I'm trying to convert a long script I have into a standalone application.
When run in Matlab, the script prompts for 4 string inputs that dictate where data will be pulled from and saved to. Essentially, I've converted these 4 prompt/input combinations into a very simple GUI. I then use VariableX = get(hObject,'String') to assign the inputs of the GUI to the corresponding variable in the original script.
Then, there's a pushbutton that calls the original script when activated. However, it seems these variables (such as VariableX) are not passed into the script, as I get the 'Undefined function or variable' error.
How can I make sure those input variables are saved so that the script can execute? And will this have implications when I ultimately turn it into a standalone file?
Thanks in advance!
  1 件のコメント
Eamon
Eamon 2016 年 10 月 7 日
I'm not sure if this is the most efficient way to do it, but you could make the variables global so that they can be accessed by multiple functions. It would not be ideal if you have variables with identical names in the different functions, but in that case you could probably just give them different names. You could also restructure the function so that you call the function with the variables as arguments in the pushbutton file, like so:
function pushbutton1(var1, var2, var3)
or
function pushbutton1(varargin)
if the number of variables you're calling changes.

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

採用された回答

Stalin Samuel
Stalin Samuel 2016 年 10 月 7 日
Here you can find the solutions for same issue which has the details of using Global variables in MATLAB GUI.Also refer this for Share Data Among Callbacks
  1 件のコメント
MJU
MJU 2016 年 10 月 12 日
Thank you! Easy fix.

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

その他の回答 (0 件)

カテゴリ

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