I had a friend that figured it out.
// Initialize Cov Matrix
emxArray_real_T *Cov = emxCreate_real_T(cols, cols);
// Initialize Lambda matrix
emxArray_creal_T *Lambda = emxCreate_creal_T(cols, 1);
// Initialize V matrix
emxArray_creal_T *V = emxCreate_creal_T(cols, cols);
int c = 0;
// Copy values from input to Cov matrix
for (int i = 0; i < cols; i++)
{
for (int j = 0; j < cols; j++)
{
Cov->data[c] = input[i][j];
c++;
}
}
// Call My_Eig function to retrieve Lambda and V matrices
My_Eig(Cov, Lambda, V);
// Copy values from Lambda and V to out_Lambda and out_V
for (int i = 0; i < cols; i++)
{
out_Lambda[i,0] = Lambda->data[i].re;
out_Lambda[i,1] = Lambda->data[i].im;
}
for (int i = 0; i < (cols * cols); i++)
{
out_V[i, 0] = V->data[i].re;
out_V[i, 1] = V->data[i].im;
}
// Before quit the function, release allocated memory
emxDestroyArray_real_T(Cov);
emxDestroyArray_creal_T(Lambda);
emxDestroyArray_creal_T(V);
My_Eig_terminate();
return;
}
Best Answer