sub diagonal of a matrix matlab code example Example: finding diagonal elements in matlab D = diag(v)