Reputation: 575
I built two binary matrices in R then loaded them to MATLAB. I want to do feature selection by the use of this function:
[steps,sel_flag,rel,red,cond_red] = select_features(BinaryMat1,BinaryMat2, 'degree', 2);
Two binary matrices are in double
format, but I got this error:
Undefined function
select_features
for input arguments of typedouble
.
What should I do to convert these two matrices to integer in Matlab? I have tried uint8
, int32
and int64
but I got the same error each time.
Upvotes: 0
Views: 1108
Reputation: 104484
Simply convert each matrix to logical
. That can be done by casting them before calling the function:
BinaryMat1 = logical(BinaryMat1);
BinaryMat2 = logical(BinaryMat2);
[steps,sel_flag,rel,red,cond_red] = select_features(BinaryMat1,BinaryMat2, 'degree', 2);
You also may be getting that error because MATLAB can't find that function to run. Make sure you have this function on your computer before running the code. The function you referenced is not part of MATLAB's native environment, but by doing a simple Google search, I found this:
Upon looking at the source, it doesn't look like the inputs are just exclusively for binary matrices. It looks like they can be any matrices so long as they represent integral types, so integer, unsigned integer could also have worked, but I highly suspect that you didn't download the toolbox correctly, or assumed that this toolbox was part of MATLAB's native libraries.
The full toolbox can be found here: http://www.mathworks.com/matlabcentral/fileexchange/submissions/26981/v/1/download/zip
This is part of a custom toolbox written by an individual independent of MathWorks, so make sure you download this toolbox, put it somewhere that is accessible, and then run the code again.
Download the toolbox, extract the contents from the archive (.zip) file, then add this directory to MATLAB's path. You can do this by either going to File->Set Path
and adding this directory to MATLAB's path, or doing this in the command prompt by:
path(path,genpath('/path/to/toolbox/dir'));
Upvotes: 1