%% Largest Element Involving NaN
% Create a vector and compute its maximum, excluding NaN values.

A = [1.77 -0.005 3.98 -2.95 NaN 0.34 NaN 0.19];
M = max(A,[],'omitnan')

% max(A) will also produce this result since 'omitnan' is the default option.
%
% Use the 'includenan' flag to return NaN.

M = max(A,[],'includenan')

% Copyright 2015 The MathWorks, Inc.