I have a MATLAB function that has been compiled into a standalone application with mcc
. When the user works with the function through the standalone application, output arguments are not used and instead I would like to ensure that the user gives an address to an output file as an input argument.
For instance, say my MATLAB function myFunc
is defined like this:
function out_mat = myFunc(nElem, varargin)
save_file = false;
if nargin == 2
save_file = true;
add_to_file = varargin{1};
end
out_mat = rand(nElem);
if save_file
% Write out_mat to address add_to_file....
end
end
When called in MATLAB, the user can define an output address (add_to_file
) or not. It is up to the user and I do not care! But if the user is using the standalone executable, I want to make sure that the user actually defines add_to_file
. So basically I want to add a condition like this to my code:
if call_in_matlab
narginchk(1,2);
else
narginchk(2,2);
end
How do I check if call_in_matlab
is true or false? In other words, how can I tell in a function is called through its compiled standalone application or in MATLAB?
CodePudding user response:
There are some functions in MATLAB to support Compiler-generated stand-alone programs. See the documentation. In particular, you want isdeployed
.