function v = diagElems(A)
%DIAGELEMS Diagonal elements of a square matrix
%   v = diagElems(A) returns a row vector of the diagonal elements of A.

[rows, cols] = size(A);
v = zeros(1, rows);
for i = 1:rows
    v(i) = A(i, i);
end

