MATLAB: Matlab Standalone exe conditional statement not working

standalone executable

Hello,
i´m working on an image registration program which will be exported by the mcc comand. The program uses an extern library which should not be included in the exe. After creating a Proto-File from the .dll and .h file and exporting the .m file as an exe the function is not working anymore. After some tests i think i might found the problem. Inside the function is a conditional if/ifelse statement to choose an image registration method. It seems like the standalone exe just skips this part and therefore multiple variables are not declared. The program then stops with the error "variable not found". I tried to replace the if-else statement with a switch case but this does not work as well. So my question is why does the standalone skip the conditional statement? Or may it be another problem?
Thank for the help!

Best Answer

From the original message:
"The flag is set as an input parameter of the function (beside two others). The first two input arguments are strings (I validated the correct input the function uses them correctly). The flag itself is just a integer."
From the documentation in the "Using a MATLAB File You Plan to Deploy" section:
"When running MATLAB files that use arguments that you also plan to deploy with MATLAB Compiler, keep the following in mind:
  • The input arguments you pass to your executable from a system prompt will be received as character vector input. Thus, if you expect the data in a different format (for example, double), you must first convert the character vector input to the required format in your MATLAB code. For example, you can use str2num to convert the character vector input to numerical data."
The char vector '1' is not equal to the double value 1.
>> '1' == 1
ans =
logical
0