I am not able to reproduce the issue at my end. But please refer to the sample code for creating a neural network using "fitrnet" function and with a dataset of size "1000x24". This code might help you resolve the issue faced.
% Generate a synthetic dataset
rng(0); % For reproducibility
numObservations = 1000;
numFeatures = 24;
% Create random data
X = rand(numObservations, numFeatures);
y = rand(numObservations, 1); % Random target variable
% Create a cvpartition object for an 80/20 split
cv = cvpartition(numObservations, 'HoldOut', 0.2);
% Get training and test indices
trainIdx = training(cv);
testIdx = test(cv);
% Split the data into training and test sets
XTrain = X(trainIdx, :);
yTrain = y(trainIdx);
XTest = X(testIdx, :);
yTest = y(testIdx);
% Set up and train a neural network regression model
try
% Define the neural network
model = fitrnet(XTrain, yTrain, 'LayerSizes', [10, 10], 'Activations', 'relu');
% Predict on the test set
yPred = predict(model, XTest);
% Calculate and display the RMSE
rmse = sqrt(mean((yTest - yPred).^2));
fprintf('RMSE: %.4f\n', rmse);
catch ME
% Display the error message if one occurs
fprintf('Error: %s\n', ME.message);
end
For more information on the "cvpartition" function, please refer to the below link.
If this does not solve your issue, please reply back with relevant files so that I can get to know the issue encountered in detail.
Thanks!
