User`s guide
mwArray R eal()
Purpose Return mwArray that references real part of complex array
C++
Syntax
#include "mclcppclass. h"
double rdata[4] = {1.0, 2.0, 3.0, 4.0};
double idata[4] = {10.0, 20.0, 30.0, 40.0};
mwArray a(2, 2, mxDOUBLE_CLASS, mxCOMPLEX );
a.Real().SetData(rdata, 4);
a.Imag().SetData(idata, 4);
Arguments None
Return
Value
An mwArray referencing the real part of the array.
Description Usethismethodtoaccesstherealpart of a complex array. The returned
mwArray is considered real and has the same dimensionality and type
as the o riginal.
Complex arrays consist o f Complex numbers, which are 1 X 2 vectors
(pairs). For example, if the number is
3+5i, then the pair is (3 ,5i).An
array of Complex numbers is therefore two dimensional
(N X 2),where
N is the number of complex numbers in the array.
2+4i, 7-3i, 8+6i
would be represented as (2,4i) (7,3i) (8, 6i). Complex numbers
have two components, real and imaginary.
The MATLAB functions
Real and Imag can be applied to an array o f
Complex numbers. These functions extract the corresponding part of
the Complex number. For example,
REAL(3,5i) == 3 an d IMAG (3+5i)
== 5
.NotethatImag returns 5 in this case and not 5i. Imag returns
the magnitude of the imaginary part of the number as a real number.
C-75