Code covered by the BSD License  

Highlights from
validateInput

Be the first to rate this file! 2 Downloads (last 30 days) File Size: 2.5 KB File ID: #27338

validateInput

by Jedediah Frey

 

22 Apr 2010

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

| Watch this File

File Information
Description

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

MATLAB release MATLAB 7.5 (R2007b)
Other requirements Tested on Windows XP. Should work on all platforms.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
input validation Jedediah Frey 22 Apr 2010 13:23:58

Contact us at files@mathworks.com