Table Of Contents

diag

Version:
    Last Modified: March 15, 2017

    Computes a diagonal matrix or the diagonal of a matrix. diag(a, 0) is equivalent to diag(a).

    Syntax

    c = diag(a)
    c = diag(a, b)

    Inputs

    a

    Vector or matrix of any data type.

    b

    Diagonal of a. b is an integer.

    Outputs

    c

    Diagonal matrix or the diagonal of a matrix. c is a vector or matrix. If a is a matrix, diag(a) returns a column vector containing the diagonal of a and diag(a, b) returns a column vector containing the bth diagonal of a. If a is a vector of length n, diag(a, b) is a square matrix of size n+ abs (b) with a bth diagonal determined by a.

    A = [1, 0, 0; 0, 2, 0; 0, 0, 3]
    C = diag(A)

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: This product does not support FPGA devices


    Recently Viewed Topics