Clear Filters
Clear Filters

How do I pass input arguments to a compiled executable and define the output arguments that the user can see?

57 views (last 30 days)
I have recently purchased the MATLAB Compiler and have a question regarding it's workflow.
I have a series of .m files that I have successfully packaged up as a standalone executable that will be released to a user without a MATLAB license. I need the user to be able to update and send input parameters to the executable for it to run and I want to define what outputs the user has visibility of.
Is there a way to achieve this workflow? Potentially as an app design that is linked to the standalone .exe?
I've included an image below showing the current workflow in MATLAB. I am passing five parameters to the main script that represent what has been compiled as an executable. There are three numerical inputs, one file and one file path.
The outputs I want the user to have sight of will all be numerical values or arrays that can be used for plotting.

Accepted Answer

Steven Lord
Steven Lord on 28 Feb 2023
See this documentation page. Defining input arguments is relatively straightforward. For output arguments see the "Using a MATLAB File You Plan to Deploy" section on that page.
Walter Roberson
Walter Roberson on 28 Feb 2023
Your system command shell breaks the command line up into separate character vectors according to its rules for quoting and special meaning for characters such as > or $ . In the absence of quotes and special characters acted upon by the shell, each sequence of consecutive non-whitespace characters will typically get treated as a separate piece. (This can cause problems if the user is not careful to put quote marks around a file name that includes whitespace.)
Once it has broken the command line into pieces, each piece is passed in a separate parameter, as text. If more pieces were provided by the user than the function is designed to expect as variables, then MATLAB will complain about too many input parameters -- and will not automatically just drop extras or bundle them into a single parameter. For this reason, if you are expecting a function to be called from the command line you are likely to code the function using varargin to permit it to accept any number of parameters (that you can then parse or ignore as appropriate for your purposes.)
system('filename Cairo 15.55')
would be received by the function with 'Cairo' (the character vector) passed as the first parameter, and with '15.55' (the character vector) passed as the second parameter. It is the responsibility of the called function to convert text to numeric as appropriate for the needs of the function.
Jack Smith
Jack Smith on 28 Feb 2023
Hi Walter,
This makes sense to me now, it was the step to convert the m files to a function before compiling that I was missing.
The process of converting inputs from characters was clear from the documentation but thanks for highlighting the issues that could occur regarding number of input parameters.

Sign in to comment.

More Answers (0)


Find more on Entering Commands 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!