Matlab nanrms
Aug 13, 2017

I often find the Matlab nanmean function very useful. Unfortunately there is no builtin to behave similarly for RMS. So here is a snippet which may yield use!

function r = nanrms(values)
% Compute the RMS of the given values, ignoring NaNs

r = [];
% For each row in the values vector/matrix, ignore NaNs
for i = 1:size(values, 2)
row = values(:, i);
nonNaNs = row(~isnan(row));
r(end + 1) = rms(nonNaNs);
end
end


Back to posts