Matlab compiler: interactive input like INPUT function
Ältere Kommentare anzeigen
When making compiled programs with the Matlab compiler, is there a way of accepting variables from the user after the program has started running?
I know that variables can be passed in as command line options when executing the program.
But I want to use something like the Matlab INPUT command (this causes an error)
Thanks.
4 Kommentare
Walter Roberson
am 15 Mai 2012
I wonder if fid 0 (standard input) and fid 1 (standard output) are connected usefully in a compiled routine?
Kaustubha Govind
am 16 Mai 2012
What is the error you get when compiling with the INPUT function? Also please mention what platform you are working on.
Walter Roberson
am 16 Mai 2012
If windows, is it a console application or a standalone application that you are producing? It would not surprise me if input() failed on a standalone application.
Edward
am 17 Mai 2012
Antworten (2)
Ahmed Saad
am 15 Mai 2012
0 Stimmen
please tell me how it can be passed in as command line options,i have the same problem
5 Kommentare
Walter Roberson
am 15 Mai 2012
The top level routine you compile must be a function (a compiler restriction). That function can have arguments. Anything typed on the command line that is not grabbed by the operating system, will be passed in as arguments to the function, as strings (NOT as numeric values!)
Ahmed Saad
am 15 Mai 2012
thank you walter,but i still did not get it well .could you explain more,sorry i am still a beginner
Walter Roberson
am 15 Mai 2012
Quick example:
function YourMainFunction(varargin)
if nargin >= 1
firstarg = str2double(varargin{1});
else
firstarg = [];
end
Ahmed Saad
am 15 Mai 2012
i did not get it work but thank you for your kind reply
Edward
am 17 Mai 2012
Edward
am 17 Mai 2012
4 Kommentare
Kaustubha Govind
am 18 Mai 2012
Strange - it looks like the entered value is getting evaluated. I wonder if input('Please input a letter... ','s') is being treated like input('Please input a letter... ') in deployed mode. What happens if you input the name of a MATLAB function like 'rand' instead of 'y'.
Walter Roberson
am 18 Mai 2012
That isn't it, Kaustubha. The error being generated is from MS Windows -- the input is going to CMD not to the program. MATLAB would complain about no routine named "y" but would not complain about it not being a batch file.
Kaustubha Govind
am 22 Mai 2012
Ah. That makes sense.
if you want this to work, you must choose "console application" NOT "windows standalone application" from the deploytool dialog. This is equivalent to compiling as:
mcc -W main -T link:exe myfunc.m
Kategorien
Mehr zu MATLAB Compiler finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!