How can I pass a variable in an app to basic workspace?

I have some variables in an app that I would like to use and list in the basic workspace. I am using Matlab 2018a and the AppDesigner, before in the GUI there was evalin(), and assignin() function for that but I tried here the same but it is not working. Any ideas?
Thank you,

4 件のコメント

Stephen23
Stephen23 2018 年 9 月 13 日

Return them as output arguments. The simplest solutions are usually the best.

" before in the GUI there was evalin(), and assignin() function ..."

Note that making variables magically appear and disappear in other workspaces is one way that beginners force themselves into writing slow, complex code. Passing variables as input/output arguments is much more efficient.

Bence Salanki
Bence Salanki 2018 年 9 月 13 日
編集済み: Bence Salanki 2018 年 9 月 13 日
Thank you for your answer. It is just for debugging and to make sure that everything is working properly.
For instance if I have a button which connects an instrument to Matlab and I want to store this instrument in a variable and have this variable in the base workspace how would you do that? It is because the button's callback function doesn't have any output parameters and I can not edit that part.
Stephen23
Stephen23 2018 年 9 月 13 日
編集済み: Stephen23 2018 年 9 月 13 日

"I have a button which connects an instrument to Matlab and I want to store this instrument in a variable and have this variable in the base workspace how would you do that?"

Personally I wouldn't, because processing data in the base workspace from any GUI is quite inefficient. It is much simpler and more efficient to process the data within the GUI.

"It is because the button's callback function doesn't have any output parameters and I can not edit that part."

Callbacks do not return any output arguments. Pass the data between GUI callbacks/workspaces using guidata (if using GUIDE) or nested functions (if sensibly writing your own code). Both of these easily allow you to output any data when the function is called, or when the GUI is closed (see waitfor).

Dennis
Dennis 2018 年 9 月 13 日

I agree with Stephen, if there is no specific reason why you need your variables in base workspace do not bother getting them there.

However i also think there is no easy way to actually get output arguments from appdesigner.

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

回答 (0 件)

カテゴリ

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

質問済み:

2018 年 9 月 13 日

編集済み:

2018 年 9 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by