Application compiler: Command line Input type options missing

I am using Application compiler for generating a standalone application. I'm following the documenttaion available here
I don't find the `Command line Input type options` shown here ( https://in.mathworks.com/help/compiler/create-and-install-a-standalone-application-from-matlab-code.html ) above Additional installer options.
I'm using 2021a.
Could someone help me with this? I'd like to include `Command line Input type options` to pass input arguments to the executable file.

 Accepted Answer

"Command line input type options" will be shown if m file is a function.
In the documentation example which you mentioned, the magicsquare.m file is a function.
function m = magicsquare(n)
if ischar(n)
n=str2double(n);
end
m = magic(n);
disp(m)
It seems that your main.m is a script file.
For detail about script vs function, this document will be helpful.

4 Comments

Hi @Kojiro Saito,
Many thanks for the clarification.
If I may ask a follow up question
I have a class with all the settings defined and this class is accessed from the main script and by other functions that are called in the main script .
classdef classname
properties (Constant)
end
methods(Static)
function test_run = select_run
test_run = struct(...
'test1',false,...
'test2',false,...
'test3',true,...
);
end
end
In the usual way, I directly change the settings in my class depending on the test case that I want to run.
i.e if I want to run `test1` , I set
test_run = struct(...
'test1',true,...
'test2',false,...
'test3',false,...
);
Here is what I intend to do while generating the standalone executable. Change main.m from `script` to `function`. And I want to change the settings of `test_run` in the ``classname` class via the main function (main(arg)).
Could you please suggest what's the best way to do this?
I am not sure I can clearly understand, but how about setting test1, test2 and test3 in properties of the class and accessing the class from main function?
classdef classname
properties
test1
test2
test3
end
methods(Static)
function test_run = select_run
test_run = struct(...
'test1',false,...
'test2',false,...
'test3',true,...
);
end
end
end
function out = main(in1)
% Use input variable
% hogehoge = in1;
myClass = classname;
% Initialize struct
myClass = myClass.select_run;
% Change struct
myClass.test1 = true;
myClass.test3 = false;
%out = blah-blah-blah;
%disp(out)
end
@Kojiro Saito Thank you , I'm sorry but I am really confused at this point. I am sharing a simple exmaple below. Hope I can explain my doubt clearly through this example
I want to do the following: define the value of Number in `classname` properties from another function `main`.
function main(arg)
classname.get_Number(arg)
end
classdef classname
properties (Constant)
%use a struct to store the defaults to keep all your static
%properties in one place
Number=classname.get_Number;
end
methods(Static)
function val=get_Number(arg)
val=arg;
end
end
end
>>main(10)
Expected result:
When I call classname.Number from other functions or class, I want it to return 10.
This document(Developing Classes — Typical Workflow) will be helpful.
There various ways to implement your class.
Simple way is the following.
classdef classname
properties (SetAccess = private)
Number
end
methods
function val=classname(arg)
val.Number=arg;
end
end
end
function out = main(arg)
myClass = classname(arg);
out = myClass.Number;
end
By the way, it's getting going away from the original question, so if you have further question, it's better to post it as another question.

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2021a

Community Treasure Hunt

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

Start Hunting!