Hi Mahmoud,
If I understood the query correctly, you're trying to preprocess a table where the first column is categorical and the remaining columns are numerical. The error occurs because 'varfun' expects a table as input: https://www.mathworks.com/help/matlab/ref/table.varfun.html#btyj4vl-1-A , but 'PrepData{:,2:end}' extracts a matrix (numeric array).
To fill the missing values in the numerical columns (using 'spline' interpolation) and correspondingly standardize the numerical data (using 'zscore'), you can refer to a below example script:
% Sample data
categories = {'Type1'; 'Type2'; 'Type1'; 'Type2'; 'Type1'};
values1 = [1.2; NaN; 3.4; 4.1; 5.6];
values2 = [10.5; 20.1; NaN; 40.3; 50.7];
data = table(categories, values1, values2, ...
'VariableNames', {'Category', 'Feature1', 'Feature2'});
disp(data)
% fill missing values
PrepData = fillmissing(data, 'spline', 'DataVariables', @isnumeric);
% Standardize numerical columns (keeping categorical)
numVars = PrepData.Properties.VariableNames(2:end); % Get numerical column names
% varfun expects table /timetable as second input argument
PrepData(:,numVars) = varfun(@zscore, PrepData(:,numVars));
disp('Preprocessed data:');
disp(PrepData);
Hope this helps!