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

17 views (last 30 days)
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

Accepted Answer

Adam
Adam on 18 Feb 2020
  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 Comment
Adam
Adam on 18 Feb 2020
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

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!