Hello Hugo,
To perform feature selection using the fscmrmr() function on a 3D matrix in MATLAB, you need to ensure that the dimensions of the matrices you pass to the function are appropriate. The fscmrmr() function is typically used for 2D matrices, where rows represent observations and columns represent features.
In this case, we have a 3D matrix Matrix with dimensions (M, N, 48) and want to use column 32 as the reference variable for feature selection.
numSlices = size(Matrix, 3);
idx1 = cell(numSlices, 1);
scores1 = cell(numSlices, 1);
slice = squeeze(Matrix(:, :, i));
referenceVar = slice(:, 32);
[idx1{i}, scores1{i}] = fscmrmr(slice, referenceVar);
- Squeeze the Slice to convert the 3D slice into a 2D matrix for each iteration.
- This code will iterate over each slice of the 3D matrix, perform feature selection using fscmrmr(), and store the results in idx1 and scores1.
Please go through these documentation links for better understanding:
- fscmrmr() - https://www.mathworks.com/help/stats/fscmrmr.html
- squeeze() - https://www.mathworks.com/help/matlab/ref/squeeze.html
Regards!