📄 nansum.m
字号:
function y = nansum(x)%NANSUM Sum ignoring NaNs.%% NANSUM(X) returns the sum over non-NaN elements of X. For% vectors, NANSUM(X) is the sum of the non-NaN elements in X. For% matrices, NANSUM(X) is a row vector containing the sum of the% non-NaN elements in each column of X.%% See also NANMEAN, NANSTD. error(nargchk(1,1,nargin)) % check number of input arguments % replace NaNs with zeros. nans = isnan(x); inan = find(nans); x(inan) = zeros(size(inan)); y = sum(x); % protect against an entire column of NaNs iall = find(all(nans)); y(iall) = NaN;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -