Hi Efstathios,
I understand that you are using the “fitcdiscr” function on a table in MATLAB and are facing the mentioned error.
You can try separating the predictor and class columns and convert them into arrays before passing them into the function.
I have created a table as per the mentioned specifications and showed how to do this in the following code:
% Recreating the table with the provided specifications
trial = rand(4, 20);
classes = cell(4, 1);
% Assigning class labels (Random)
classes{1} = 'c1';
classes{2} = 'c2';
classes{3} = 'c1';
classes{4} = 'c1';
% Table with the given specifications
table = array2table(trial);
table.class = classes;
% Converting the predictor variables to seperate array
columnsToConvert = 1:20;
predictorColumns = table(:, columnsToConvert);
predictors = table2array(predictorColumns);
% Class array
classesColumn = table2array(table(:, 21));
% Using the fitcdiscr function
fit = fitcdiscr(predictors, classesColumn);
Here, I am assuming that all the required data is already there, so I have just showed how to perform indexing on some randomly generated data.
For more information about the above used functions, please refer to the following documentation:
- Fit discriminant analysis classifier: https://in.mathworks.com/help/stats/fitcdiscr.html
- Cell Arrays: https://in.mathworks.com/help/matlab/ref/cell.html
- Convert table to homogenous array: https://in.mathworks.com/help/matlab/ref/table2array.html
Hope this information helps!
Best Regards,
Moksh Aggarwal