Complex number determination

How can I check if a number is imaginary? I want to set an if function, that if a variable is an aimginary number then something will happen.

 Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 3 de En. de 2012

5 votos

z - your number
out = imag(z) ~= 0;
if out = true, then z - complex number
OR
out = isreal(z)
if out = false, then z - complex number

Más respuestas (0)

Categorías

Productos

Etiquetas

Preguntada:

el 3 de En. de 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by