Matlab Standalone exe conditional statement not working
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Fabian Lübbert
il 23 Ago 2017
Commentato: Fabian Lübbert
il 23 Ago 2017
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!
5 Commenti
Adam
il 23 Ago 2017
The only option then is that the flag is not actually precisely equal to any of those options, either because it is somehow being inaccurately represented as a double or because it is actually a string or because for some reason it doesn't exist at that point.
If there was no output from disp it suggests that for some reason the flag variable does not exist at that point, although I'd assume there would be an error in that case, assuming the disp is immediately before the if statement.
You could also test by adding an else to your statement to catch all other cases and put a sprintf to output the flag with many decimal places in the else block.
Risposta accettata
Steven Lord
il 23 Ago 2017
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."
"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
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!