File Exchange

image thumbnail

validateInput

version 1.0 (2.5 KB) by

A simple 'getOpts' type script to validate input parameters.

1 Download

Updated

View License

validateInput started when creating saveppt2. There was a need to take a large number of inputs, in any order, and make them usable to the script. Checking if an input argument has been passed can be done with isfield or if the 'force' option is enabled if the field is false.

Examples:
varargin={'p','s',10,'name','john doe'};
validParameters={{'size','s'},{'print','p'},'name'};
parameters=validateInput(varargin,validParameters)
parameters =
print: 1
size: 10
name: 'john doe'

varargin={'p'}
validParameters={{'size','s'},{'print','p'},'name'}
parameters=validateInput(varargin,validParameters,true)

parameters =
print: 1
size: 0
name: 0

Comments and Ratings (1)

Sachin

Sachin (view profile)

MATLAB Release
MATLAB 7.5 (R2007b)
Acknowledgements

Inspired: saveppt2

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today