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

24 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.
  3 Comments
Jarrett Liner
Jarrett Liner on 27 Jan 2022
yeah, the question is all over the place.
I wrote a matlab script, .m It works well
other users may have a problem changing the variables.
that prompted me to create a GUI in app designer. (.mlapp)
I have an app (.mlapp) with the variable inputs (text and numeric fields).
I want to use those app inputs in my original matlab script (.m)
I researched, and I found that I could convert the .mlapp to a .m script. I did that. ran it as a (.m) script, the GUI was created that looks exactly like the GUI from the app designer .mlapp.
now I have the GUI and the origial script both in matlab as seperate .m scripts. (maybe this is not the way to do it)
I was thinking I could add my original script (.m) to the converted (from .mlapp to .m) GUI script and call the user input variables.
I dont know where to insert the origianl script in to the converted script to be useful. I am sure this is the wrong way to do this. thanks for wanting to help.
Rik
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
Hi,
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:

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!