MATLAB: Can I pass a file to a MATLAB Compiler generated application as an argument by dragging the file to the application’s icon on a Windows machine

argumentcompiledragdropfileMATLAB Compilerparameterpassingprogramwindows

I have a MATLAB program that takes a file name as its only input argument (as a string). I have compiled this application and can run it from the Windows/DOS command prompt by typing the program name and the file name that I am passing to it. I would like to simplify this process by dragging the input file to my program's icon and have the file name be recognized by my program as its input argument.

Best Answer

The ability to drag files to be used as a program's input is provided by Windows. You can create a shortcut to your program and then drag the input file to the shortcut icon rather than the program icon itself. Windows will then run your program and pass the dragged file's name to it as an input argument.
Note that this is a feature in Windows and not of MATLAB Compiler. MathWorks cannot guarantee that this procedure will work on all versions of Windows.