Reputation: 9806
I have matrix say a in matlab. I wish to some feature selection using relieff function.
The problem I have is that some values in the matrix are complex numbers. How can I convert the complex numbers to represent their magnitude in the matrix?
Upvotes: 1
Views: 109
Reputation: 114796
You can find the complex valued entries in your matrix A
using
cmplx = imag(A) ~= 0;
Once you found them, you can replace them
A(cmplx) = abs( A(cmplx) );
Note that requiring floating-point numbers to be exactly zero might be too restrictive and a threshold might be needed instead, e.g.,
cmplx = abs( imag(A) ) > 1e-8;
Upvotes: 2