MATLAB: Is it possible to pre-define user input values and skip input dialogs in a script

inputdlgsuppress dialogs

I'm trying to work out a simple script right now that will enable us to run a sequence of 2-3 other Matlab extensions for Imaris (an image analysis program). My goal is to have a single prompt at the beginning of this script asking the user for the necessary inputs, which will then be used as parameters for the appropriate extensions, allowing the user to set up a lengthy sequence of analysis without needing to baby-sit the program.
The problem is that each of these extension scripts currently get their parameters via dialog prompts (e.g. inputdlg). I need to somehow suppress these dialog prompts and pass the appropriate values from my own script instead, but as far as I know there is no way to do this without modifying the code for each extension. I've tried to run a script in "batch" mode using the batch() function, which sounds like it might do what I want, but I can't seem to pass any variables to it, and I suspect I'm fundamentally misunderstanding the input arguments or perhaps the function overall.
Is there an easier method to do this? Or rather, is it even possible? Or am I better off just creating a custom version of each extension?

Best Answer

Is there an easier method to do this? Or rather, is it even possible? Or am I better off just creating a custom version of each extension?
Possible? Perhaps, through some trickery involving shadowing inputdlg. But I would strongly recommend that instead you modify (or work with the extension authors to modify) the extensions to only ask for the inputs interactively if they did not receive inputs from their caller, via something like:
if nargin == 0
theInputs = interactivelyPromptForInputsUsingInputdlg();
end
This will preserve the existing behavior, where the extensions prompt when used interactively, while allowing you to pass information in and skip the prompt when used programmatically.
Related Question