Why does INPUT interpret negative numbers as strings when compiled with MATLAB Compiler 4.0 (R14)?
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 27 Jun. 2009
Bearbeitet: MathWorks Support Team
am 16 Apr. 2023
I used INPUT to prompt the user for arguments to pass into my function. When run inside MATLAB, both positive numbers and negative numbers are interpreted as double-precision matrices inside of the function. However, when I compile the function and run it in stand-alone mode, positive numbers are interpreted as matrices, but negative numbers are interpreted as strings. The following function reproduces this behavior:
function inputtest
y=input('Enter a number: ');
if ischar(y)
disp('Number interpreted as string');
elseif isnumeric(y)
disp('Number interpreted as matrix');
end
Akzeptierte Antwort
MathWorks Support Team
am 20 Feb. 2023
Bearbeitet: MathWorks Support Team
am 16 Apr. 2023
This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
We have verified a bug in MATLAB Compiler 4.0 (R14) in the way that INPUT handles negative numbers as inputs when executed in stand-alone mode. To work around this issue, try testing the input to see if it is interpreted as a matrix or a string. If it is interpreted as a string but you know that it should be a number, use STR2NUM to convert it.
You might also consider using a different method for passing input arguments to the function. For example, try using the INPUTDLG function to prompt for inputs in a dialog box or create a graphical user interface for your function.
For more details on how to pass arguments to compiled functions, see the following solution:
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Compiler finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!