MATLAB: How to pass cell array input to the standalone application compiled with MATLAB Compiler 4.5 (R2006b)

aloneMATLAB Compilerstandstand-alone

I am looking for an example that demonstrates how to pass cell array input to a MATLAB Compiler-generated standalone application.

Best Answer

Here is one way to do this by passing the cell array at runtime as a string and having your MATLAB 7.3 (R2006b) code create the variable using EVAL:
function celltest(input_cell)
if(strcmp(class(input_cell), 'char' ))
eval(['input_cell = ' input_cell]);
end
for i = 1:size(input_cell,2)
disp(input_cell{i});
end;
In this example, whenever the input is passed as a string (at runtime), EVAL is executed to create the cell array that will then be used throughout the rest of the program.
If the input is not in string format, i.e. when the code is executed at the MATLAB prompt, the code assumes the input is in cell array format without any further checks.
To run the code in MATLAB, execute the command
celltest {'hello' 'world'}
To compile the example, execute the command
mcc -m celltest
and then execute the program as follows:
!celltest "{'hello' 'world'}"
For more information on passing arguments to standalone applications, refer to the following documentation:
web([docroot,'/toolbox/compiler/f13-1006802.html'])