Glcm (feature extraction method) give me an output in 'struct' type, while i need the output in 'double' type. I need a 'double' type as the input variable for the next step.
So, I've tried to convert it using several code showed below.
[gl] = glcm (B);
[gl] = struct2cell (gl);
[gl] = cell2mat (gl);
[fetrain] = double (gl);
The code give me an output but it's in 'complex double' type.
Is there a better way to convert 'struct' to 'double' type?
Or to convert 'complex double' to 'double' type?
Any help and suggestion would be very appreciated. Thank you.
First of all, rather than first converting to a cell and then to a matrix, you can convert directly from a
struct
to adouble
usingstruct2array
.That aside, there is no difference between a "complex
double
" and adouble
. They are both of typedouble
.You can use
real
to get the real component of the complex number orabs
if you need the magnitude of it.In your case this would be:
Update
By default
struct2array
concatenates the data horizontally. If you want your data to be a matrix that isnFields x nData
, then you could do something like the following: