Main Content

zeros

Create quaternion array with all parts set to zero

Since R2021a

Description

quatZeros = zeros("quaternion") returns a scalar quaternion with all parts set to zero.

example

quatZeros = zeros(n,"quaternion") returns an n-by-n matrix of quaternions.

example

quatZeros = zeros(sz,"quaternion") returns an array of quaternions where the size vector, sz, defines size(quatZeros).

example

quatZeros = zeros(sz1,...,szN,"quaternion") returns a sz1-by-...-by-szN array of quaternions where sz1,…,szN indicates the size of each dimension.

example

quatZeros = zeros(___,"like",prototype,"quaternion") specifies the underlying class of the returned quaternion array to be the same as the underlying class of the quaternion prototype.

example

Examples

collapse all

Create a quaternion scalar zero.

quatZeros = zeros("quaternion")
quatZeros = quaternion
     0 + 0i + 0j + 0k

Create an n-by-n array of quaternion zeros.

n = 3;
quatZeros = zeros(n,"quaternion")
quatZeros = 3x3 quaternion array
     0 + 0i + 0j + 0k     0 + 0i + 0j + 0k     0 + 0i + 0j + 0k
     0 + 0i + 0j + 0k     0 + 0i + 0j + 0k     0 + 0i + 0j + 0k
     0 + 0i + 0j + 0k     0 + 0i + 0j + 0k     0 + 0i + 0j + 0k

Create a multidimensional array of quaternion zeros by defining array dimensions in order. In this example, you create a 3-by-1-by-2 array. You can specify dimensions using a row vector or comma-separated integers.

Specify the dimensions using a row vector and display the results:

dims = [3,1,2];
quatZerosSyntax1 = zeros(dims,"quaternion")
quatZerosSyntax1 = 3x1x2 quaternion array
quatZerosSyntax1(:,:,1) = 

     0 + 0i + 0j + 0k
     0 + 0i + 0j + 0k
     0 + 0i + 0j + 0k


quatZerosSyntax1(:,:,2) = 

     0 + 0i + 0j + 0k
     0 + 0i + 0j + 0k
     0 + 0i + 0j + 0k

Specify the dimensions using comma-separated integers, and then verify the equivalence of the two syntaxes:

quatZerosSyntax2 = zeros(3,1,2,"quaternion");
isequal(quatZerosSyntax1,quatZerosSyntax2)
ans = logical
   1

A quaternion is a four-part hyper-complex number used in three-dimensional representations. You can specify the underlying data type of the parts as single or double. The default is double.

Create a quaternion array of zeros with the underlying data type set to single.

quatZeros = zeros(2,"like",single(1),"quaternion")
quatZeros = 2x2 quaternion array
     0 + 0i + 0j + 0k     0 + 0i + 0j + 0k
     0 + 0i + 0j + 0k     0 + 0i + 0j + 0k

Verify the underlying class using the classUnderlying function.

classUnderlying(quatZeros)
ans = 
'single'

Input Arguments

collapse all

Size of square quaternion matrix, specified as an integer value. If n is 0 or negative, then quatZeros is returned as an empty matrix.

Example: zeros(4,"quaternion") returns a 4-by-4 matrix of quaternion zeros.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output size, specified as a row vector of integer values. Each element of sz indicates the size of the corresponding dimension in quatZeros. If the size of any dimension is 0 or negative, then quatZeros is returned as an empty array.

Example: zeros([1,4,2],"quaternion") returns a 1-by-4-by-2 array of quaternion zeros.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Quaternion prototype, specified as a quaternion object.

Example: zeros(2,"like",quat,"quaternion") returns a 2-by-2 matrix of quaternions with the same underlying class as the prototype quaternion, quat.

Size of each dimension, specified as two or more comma-separated integers.

  • If the size of any dimension is 0, then quatZeros is returned as an empty array.

  • If the size of any dimension is negative, then it is treated as 0.

Example: zeros(2,3,"quaternion") returns a 2-by-3 matrix of quaternion zeros.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

Quaternion zeros, returned as a quaternion object or an array of quaternion objects.

Given a quaternion of the form Q=a+bi+cj+dk, a quaternion zero is defined as Q=0+0i+0j+0k.

Data Types: quaternion

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2021a

See Also

Functions

Objects