why do i get 'support for 'nargin' in a script has been removed?

29 views (last 30 days)
Error using narginchk
You can only call nargin/nargout from within a MATLAB function.
% Set default values for embedding parameters.
t = 1;
m = 1;
% Set input arguments
if nargin > 2
t = varargin{3};
if nargin > 1
m = varargin{2};

Answers (2)

Cris LaPierre
Cris LaPierre on 8 Mar 2023

Steven Lord
Steven Lord on 8 Mar 2023
Script files aren't allowed to have input or output arguments. Therefore it doesn't make sense to ask how many inputs or outputs the script file has. In release R2016b the nargin, nargout, and inputname functions started throwing errors when called from within a script.


Find more on Argument Definitions in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by