I want to use a .mlapp to input user variables into my .m code

23 views (last 30 days)
:noob, take it easy on me.
I wrote a script to control a set of RF test instruments (spectrum analyzer, Signal Generator...)
Mostly just SCPI commands. the script works well.
I want to give this to other stakeholders, but it may be difficult for them to find and enter the user variables (TCIP address, intrument settings...) whithin the script.
The app designer looks like a great way to implement a GUI for this script.
I need help understanding how to merge the script (.m) and the app (.mlapp).
I converted the .mlapp to a .m by "save/Export to .m file"
where do I insert my script?
is that even the right (best) way to get what I want?
how do I get the GUI portion to run (get created), then wait for the user to enter the variables before continuing?
I can imagine an "execute" button on the GUI that would run the script, and the script would grab the variables from the GUI.
change the variables and "execute" again with the new variables.
any help would be greatly appreciated. If I can make this happen, there will be happiness spread across the land.
Rik on 28 Jan 2022
Your script should be a function, then you can easily call it (either from inside the mlapp, or the m file).

Sign in to comment.

Answers (1)

Reshma Nerella
Reshma Nerella on 3 Feb 2022
To take input from your app created using app deisgner, you can use uicomponents like edit fields(text or numeric), drop down etc.You can add a button in your app, that user can click once all the inputs are filled. Add a button clicked function(callback for the button). When clicked, retrieve the input values required from the uicomponents. To call your script, you can
  1. Save the uicomponents values in base workspace and then call your.m script.
  2. Convert the script to a function and pass them as input arguments to your function.
Here are the few links for your reference:


Find more on Material Sciences 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!