9.5 Transferring data fromMatlabto the C++ domain 311
}
//--- Retrieve the eigenvalue matrix:
mxArray * Eig = engGetVariable(bouboulina, "D");
double * D = mxGetPr(Eig);
//--- real (ER) and imaginary (EI) parts of the eigenvalue matrix
double ER[N][N];
double EI[N][N];
Ic=-1;
for (int j=0; j<=N-1; j++)
{
for (int i=0; i<=N-1; i++)
{
Ic=Ic+1;
ER[i][j]=D[Ic];
Jc = Ic+N*N;
EI[i][j]=D[Jc];
}
}
//--- Print the real part of the eigenvalue matrix:
cout << endl;
for (int i=0; i<=N-1; i++)
{
for (int j=0; j<=N-1; j++)
{
cout << setprecision(5) << setw(10) << ER[i][j] << " ";
}
cout << endl;
}
//--- Print the imaginary part of the eigenvalue matrix:
cout << endl;
for (int i=0; i<=N-1; i++)
{
for (int j=0; j<=N-1; j++)
{
cout << setprecision(5) << setw(10) << EI[i][j] << " ";
}
cout << endl;
}