ABSTRACT

MATLAB provides a number of functions for carrying out routine operations when appropriate inputs are given. To understand functions, it’s useful to explore how built-in MATLAB functions work. This first problem is about MATLAB’s size, length, and numel functions. The length function yields the larger of the number of rows and columns. If the function returns NaN, that means there is a NaN value in the data set. The function doesn’t do what’s expected because it clears all the variables, which it should, but those variables are local to that function, which was not taken into account. The function is supposed to yield a Boolean value corresponding to whether any element of the matrix called candidates is in the matrix called full_set. MATLAB requires functions to start with the word function. The error was in the way the function was called, not in the function itself—though, ideally, the function should have only allowed for “legal” inputs.