getMessage(); } if (($suffix == 'i') || ($suffix == 'j') || ($suffix == '')) { $complex = new ComplexObject($realNumber, $imaginary, $suffix); return (string) $complex; } return Functions::VALUE(); } /** * IMAGINARY. * * Returns the imaginary coefficient of a complex number in x + yi or x + yj text format. * * Excel Function: * IMAGINARY(complexNumber) * * @param string $complexNumber the complex number for which you want the imaginary * coefficient * * @return float|string */ public static function IMAGINARY($complexNumber) { $complexNumber = Functions::flattenSingleValue($complexNumber); try { $complex = new ComplexObject($complexNumber); } catch (ComplexException $e) { return Functions::NAN(); } return $complex->getImaginary(); } /** * IMREAL. * * Returns the real coefficient of a complex number in x + yi or x + yj text format. * * Excel Function: * IMREAL(complexNumber) * * @param string $complexNumber the complex number for which you want the real coefficient * * @return float|string */ public static function IMREAL($complexNumber) { $complexNumber = Functions::flattenSingleValue($complexNumber); try { $complex = new ComplexObject($complexNumber); } catch (ComplexException $e) { return Functions::NAN(); } return $complex->getReal(); } }