abdulhaq-e
abdulhaq-e

Reputation: 626

MATLAB command to call a specific input argument when using varargin

I'm looking for a command to do something like this: say I have a function

function [] = myfunction(varargin)

then in my code, I would like to to operate on one of the inputs, say input 2, so:

if input(2) == 0

a command similar to input is what I'm looking for, does it exist?

Upvotes: 1

Views: 151

Answers (1)

Pursuit
Pursuit

Reputation: 12345

Do you mean:

if varargin{2} == 0

Or, more robustly

if (nargin>1) && (varargin{2} == 0)

Upvotes: 3

Related Questions