%% Specialized Matrix Functions
% MATLAB has a number of functions that create different kinds of matrices. Some create specialized matrices like the Hankel or Vandermonde matrix. Most of these functions return matrices of type double (double-precision floating point). However, you can easily build basic arrays of any numeric type using the ones, zeros, and eye functions. To do this, specify the MATLAB class name as the last argument:

A = zeros(4, 6, 'uint32')

%% Creating a Magic Square Matrix
% A magic square is a matrix in which the sum of the elements in each column, or each row, or each main diagonal is the same. To create a 5-by-5 magic square matrix, use the magic function as shown. Note that the elements of each row, each column, and each main diagonal add up to the same value: 65.

A = magic(5)

%% Creating a Diagonal Matrix
% Use diag to create a diagonal matrix from a vector. You can place the vector along the main diagonal of the matrix, or on a diagonal that is above or below the main one, as shown here. The -1 input places the vector one row below the main diagonal:

A = [12 62 93 -8 22];
B = diag(A, -1)

% Copyright 2018 The MathWorks, Inc.