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

47 次查看(过去 30 天)
narginchk(1,3)
Error using narginchk
You can only call nargin/nargout from within a MATLAB function.
nargoutchk(0,1)
%%
% Set default values for embedding parameters.
t = 1;
m = 1;
%%
% Set input arguments
if nargin > 2
t = varargin{3};
end
if nargin > 1
m = varargin{2};
end

回答(2 个)

Cris LaPierre
Cris LaPierre 2023-3-8

Steven Lord
Steven Lord 2023-3-8
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.

类别

Help CenterFile Exchange 中查找有关 Argument Definitions 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by