Main Content

imag

Imaginary part of complex number

Description

example

Y = imag(Z) returns the imaginary part of each element in array Z.

Examples

collapse all

Find the imaginary part of the complex number Z.

Z = 2+3i;
Y = imag(Z)
Y = 3

Find the imaginary part of each element in vector Z. The imag function acts on Z element-wise.

Z = [0.5i 1+3i -2.2];
Y = imag(Z)
Y = 1×3

    0.5000    3.0000         0

Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, or multidimensional array. imag operates element-wise when Z is nonscalar.

Extended Capabilities

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

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.

Version History

Introduced before R2006a

See Also

| | | | |