필터 지우기
필터 지우기

Input and output arguments in App Designer

조회 수: 20 (최근 30일)
Neil
Neil 2016년 5월 16일
답변: Sebastian Bech-Terkilsen 2018년 8월 30일
I am trying to make a GUI using App Designer in R2016a and can't figure out how to set input/output arguments. In GUIDE, there is the OpeningFcn that includes varargin for command line arguments, but I see nothing comparable in App Designer. I thought that adding the variables to the following part of code would work, but it is uneditable.
% Construct app
function app = MyApp()
As for the output, if I call the gui from the command line like this.
out = MyApp;
then out appears to be the entire app object. However, I would like to only output specific variables.
I have checked the examples provided and searched the mathworks site but haven't found an explanation.
-Neil

채택된 답변

Melissa Williams
Melissa Williams 2016년 5월 18일
편집: Melissa Williams 2016년 5월 18일
Hi Neil,
This isn't currently supported in App Designer for 16a. However it is on our radar and planned to be supported in an upcoming release.
Can you tell me more about what you are trying to do with output arguments?
-Melissa
  댓글 수: 1
Chris Portal
Chris Portal 2018년 4월 22일
As of R2017b, input arguments can be passed into the app when the app is created.

댓글을 달려면 로그인하십시오.

추가 답변 (4개)

Sebastian Bech-Terkilsen
Sebastian Bech-Terkilsen 2018년 8월 30일
Hi Neil,
If the output variable you want to transfer to your global workspace has public access in the app, then it is in the application structure, if you were to call the app like so:
[output] = myapp; % without input arguments, myapp(input,input) with input arguments.
then your output variable is output.(variablename) I noticed though that it is only accessable while the app is open. So you may either assign a new variable like:
newvariable = output.variable;
While the app is open (once you close the app the structure "output" remains but with an empty variable).
Your second option, more intuitive, is to create a button with a push callback as follows:
assignin('base',variablename,variable) % saves the variable "variable" to the base(global) workspace with the name "variablename".

Melissa Williams
Melissa Williams 2016년 5월 21일
  댓글 수: 1
Neil
Neil 2016년 5월 23일
Thanks Melissa. Chris' workaround should suffice.

댓글을 달려면 로그인하십시오.


Geoffrey Vincent
Geoffrey Vincent 2017년 5월 10일
Hello, The app designer editor is locked. But you can copy-paste all the code in a classic .m file.
After this you can pass arguments through the constructor and the output method of the app class.
But if you still want to edit the GUI with the design view you cannot re-copy-paste the code inside the designer editor. So do the trick only when your GUI is close to be finish.

Tim Van Poucke
Tim Van Poucke 2017년 12월 1일
Is in 2017b the problem already resolved, that there can be output from the app?

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by