How to set an optional function input as a first input?
Ältere Kommentare anzeigen
I am trying to make a function with syntax similar to plot(ax, ...), where the handle to an axis can be included before the required inputs, but is optional. Such as:
function add2plot(ax, x, y, varargin)
Everything I have found forces the required inputs to be first, including inputParser and manual parsing of varargin. So how does plot() do it?? I am using ver. 2013b, where the handle is a double, and thus hard to distinguish from my numerical x input. The addition of varargin makes using nargin complicated.
Any input is appreciated!
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Argument Definitions finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!