%% Create Uncertain Diagonal Matrix from Uncertain Vector
% Create an uncertain matrix MV in which the diagonal elements are the elements of an uncertain vector V, and the off-diagonal elements are all 0.  First, create the uncertain vector V.

a = ureal('a',10);
b = ureal('b',5);
V = [1+a 2 3-b 4]

%
% V is a 1-by-4 umat uncertain matrix, or in other words, an uncertain row vector with four elements. Create MV such that the diagonals of MV are the elements of V.

MV = diag(V)

%
% To verify that MV is a diagonal matrix, examine its nominal value.

MV.NominalValue

%
% Next, create a matrix in which V forms the elements of the first diagonal below the main diagonal.

MV1 = diag(V,-1)
MV1.NominalValue

%
% Copyright 2020 The MathWorks, Inc.