From 12:00 PM - 4:00 PM CST on Thursday, October 18, ni.com will be undergoing system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

diag (MathScript RT Module Function)

LabVIEW 2012 MathScript RT Module Help

Edition Date: June 2012

Part Number: 373123C-01

»View Product Info
Download Help (Windows Only)

Owning Class: linalgebra

Requires: MathScript RT Module

Syntax

c = diag(a)

c = diag(a, b)

Description

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

Examples

Inputs

Name Description
a Specifies a vector or matrix of any data type.
b Specifies a diagonal of a. b is an integer.

Outputs

Name Description
c Returns a 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.

Details

The following table lists the support characteristics of this function.

Supported in the LabVIEW Run-Time Engine Yes
Supported on RT targets Yes
Suitable for bounded execution times on RT Yes

Examples

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

Related Topics

blockdiag
tril
triu

WAS THIS ARTICLE HELPFUL?

Not Helpful