I was just writing a Matlab function and wanted to copy and paste what I had to an interactive session. Some of it was nargin statements (e.g. if nargin < 1; a = 0; end;), and it turns out that nargin had the value 11005 in my workspace, without my having assigned it. Does anyone know what this is, whether it is used for anything (outside of functions) and if there is any problem with setting it to zero?
I was just writing a Matlab function and wanted to copy and paste what
Share
When used within a function,
nargingives the number of parameters passed to that function. Used with a string argumentfnit is an in-built function, which returns the number of parameters taken by functionfn. You should not call it without a parameter from the workspace:You can, but you should avoid assigning a value to
nargin, since it will then loose the second semantics: