看看这个script
function [m,s] = stat3(x)
arguments % valid for MATLAB® R2019b and later.
x (1,:) {mustBeNumeric, mustBeFinite}
end
n = length(x);
m = avg(x,n);
s = sqrt(sum((x-m).^2/n));
end
运行此行
values = [12.7, 45.4, 98.9, NaN, 53.1];
[ave,stdev] = stat3(values)
产生此错误
Invalid input argument at position 1. Value must be finite.
很显然,NaN
不在位置1。关于错误消息中position
的含义的任何说明吗?