What are the options to use a script in app designer? and how to define it?

조회 수: 19 (최근 30일)
Sakolo
Sakolo 2020년 2월 18일
댓글: Adam 2020년 2월 18일
I have some scripts that should be ran sequentially. Each script contains many variables and matrixes and also is dependent on some variables or outputs from the previous scripts. I would like to design a GUI using app designer for all this scripts. I am facing a lot of problem and might be asking really basic/naive questions here. I appreciate if someone can help me out.
  1. Do I have to convert the scripts into functions in order to use them in app designer?
  2. Should I add all the variables in properties? If so, do I need to use app.myproperties=[] in the push button part?
  3. I have also some matrixes in my scripts that I don’t know how to deal with in the appdesigner.
  4. For converting scripts into a function can I just use as mentioned here? When should I use "[output]=MyFunction(inputs)"?
  5. How to set global variables in app designer?
Best,
Sakolo

채택된 답변

Adam
Adam 2020년 2월 18일
  1. You don't have to, but you should want to as scripts are not suitable for going beyond just trying things out. Once you want to put a GUI on it you need to design it more carefully.
  2. You can add a private properties block for variables. Personally I would factor my code out into different classes and functions, but if you want the simplest conversion then yes, you can just throw all your variables into properties.
  3. Matrices work the same in appdesigner as anywhere else. Each function in appdesigner has a workspace like all other functions.
  4. In general, yes, though if you want it to be a function on your app class then you would need to add it on there, which I'm fairly sure you can read up on in the app designer help.
  5. Don't do it. Don't do it anywhere, but in a class it makes even less sense than anywhere else since you can add properties to the class that all its functions have access to anyway.
  댓글 수: 1
Adam
Adam 2020년 2월 18일
app is the object of the class, onto which you have added all those properties. Properties are accessed from the object as e.g.
app.spacing

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

추가 답변 (0개)

카테고리

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