%% Extract Diagonal Elements of Uncertain Matrix
% Obtain a vector by extracting the diagonal elements of an uncertain matrix. First, create an uncertain matrix.

a = ureal('a',10);
b = ureal('b',5);
M = [1+a 2 3+b; 4 5+a 6; 7 8 9]

% M is a 3-by-3 uncertain matrix. Extract the diagonals of M into a three-element column vector.
%

VM = diag(M)

% VM is a 3-by-1 umat, or an uncertain column vector. Note that V depends only on the uncertain parameter a, because the diagonal elements of M do not depend on b.
%
% Next, extract a vector containing the elements of the first diagonal below the main diagonal of M.

VM1 = diag(M,-1)

%
% This vector contains no uncertain elements at all.  Examine its values.

VM1.NominalValue

%
% Copyright 2020 The MathWorks, Inc.