if nargin < 5, s_verbose = 'on'; end
if nargin < 4, s_interactive = 'off'; end
if nargin < 3, lastEig = size(vectors, 1); end
if nargin < 2, firstEig = 1; end

 Accepted Answer

James Tursa
James Tursa on 7 Mar 2017
Edited: James Tursa on 7 Mar 2017
You don't show the entire code, but my guess would be this is inside a function that looks something like this:
function outputs = myfunction(vectors,firstEig,lastEig,s_interactive,s_verbose)
if nargin < 5, s_verbose = 'on'; end
if nargin < 4, s_interactive = 'off'; end
if nargin < 3, lastEig = size(vectors, 1); end
if nargin < 2, firstEig = 1; end
:
etc
nargin is a function that returns the actual number of arguments passed into a function. So the code in question is simply assigning default values for those arguments that were not actually passed in. E.g., if the caller only passed in four arguments and did not pass in that last s_verbose argument, then the above code would assign the value 'on' to the s_verbose local variable.

1 Comment

why i use this nargin if i dont need it in my code and not passed in E.G

Sign in to comment.

More Answers (0)

Categories

Find more on Argument Definitions in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!