Stuart’s MATLAB Videos

Watch and Learn

Trying Out inputparser

I’m going to try to use inputparser for the first time, to specify name-value pair parameters for my function.

Its been around for several years but I haven’t used it. Typically my functions are “old school” where parameters need to be in certain positions. I use varargin for optional additional parameters, followed by some logic to set default values should later parameters not be present.

Currently I have a function which already has a few parameters, and I want to add more. With positional parameters, you have to supply all the ones up to the one you need which can get cumbersome if there are many. So I thought I would try using inputparser and make some of the parameters name-value pairs. This will give more flexibility in allowing only certain parameters to be specified.

Features covered in this code-along style video include:

Video Player is loading.
Current Time 0:00
Duration 20:51
Loaded: 0.79%
Stream Type LIVE
Remaining Time 20:51
 
1x
  • Chapters
  • descriptions off, selected
  • captions off, selected
  • en (Main), selected

    Play the video in full screen mode for a better viewing experience. 

    |
    • print

    Comments

    To leave a comment, please click here to sign in to your MathWorks Account or create a new one.

    Loading...
    Go to top of page