I have a GUI that takes user defined inputs, and I want the user to be able to press a pushbutton on the GUI that then runs the .m script using the variables.
So i have, for the push button:
% --- Executes Setup Balance on button press
function pb_balance_Callback(hObject, eventdata, handles)
% hObject handle to pb_balance (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
run BalanceSetup
Where the button is called pb_balance and the .m script is called BalanceSetup. Will this work or do i need a different command to run it? The .m file is 500 lines long so i don't want to include it in my .m file for the GUI.
Thanks

 採用された回答

Matt Fig
Matt Fig 2012 年 9 月 11 日

0 投票

You don't need to type run. Just the name of the script will cause the script to execute.

9 件のコメント

Tom
Tom 2012 年 9 月 11 日
so in the same place that i currently have the file name, but without run?
Matt Fig
Matt Fig 2012 年 9 月 11 日
Yes. Note that if BalanceSetup is a script and not a function then any variables created by the script will exist in the callback workspace, not the base workspace. If this is the last line of the callback, as you seem to show, then those variables will disappear once the callback is done. If this is fine, then proceed. If you expect those variables to appear in the base workspace, then you will need to do something else.
Tom
Tom 2012 年 9 月 11 日
Thank you!
James
James 2013 年 6 月 24 日
If Tom were to expect those variables to exist in the base workspace, what would have have to do?
Sean de Wolski
Sean de Wolski 2013 年 6 月 24 日
doc evalin
or
doc assignin
But we generally recommend against this
AC_Bharath MIT - Anna University (M.Tech)
編集済み: AC_Bharath MIT - Anna University (M.Tech) 2013 年 9 月 30 日
Thankyou guys for the information...
Tadgh
Tadgh 2014 年 1 月 15 日
How do i create a file labelled start that will run a script file once selected. Everything else is run from the script file but its a model so i would like the user not to have to see all the code behind it?
Any help would be greatly appreciated...
Tadgh
Tadgh 2014 年 1 月 16 日
Yes but I can't get it to work using what is discussed in that thread. I was hoping if somebody else had another idea on how to get it to work.
Thanks

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFunction Creation についてさらに検索

製品

質問済み:

Tom
2012 年 9 月 11 日

コメント済み:

2014 年 1 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by