In Matlab when one tries to access an element of a matrix that doesn't exist usually an error is raised:
>> month(0)
??? Subscript indices must either be real positive integers or logicals.
I was wondering whether there is a function that allows supplying default value in such cases. E.g.,:
>> get_def(month(0), NaN)
ans =
NaN
P.S. I can workaround this particular case of subscript (0
), but I was wondering about more generic way of doing this.