I understand that you are facing the "Invalid training data" error for your LSTM model. This error suggests that there is a mismatch between the number of observations in the predictors and the responses. After going through your code, I have found the following:
1) The reshaping of "DataParts" into "XTrain", "Ttrain" and "VTrain" looks incorrect. You have reshaped the entire dataset into a single cell. But each sequence or sample must be in a separate cell according to the correct format. You'll need to apply similar corrections to your validation and test sets.
You can take a look at the below code to understand how it must be done:
% Assuming Train1_inputX1 is a cell array where each cell contains a sequence
XTrain = cell(size(Train1_inputX1));
for i = 1:length(Train1_inputX1)
tempData = Train1_inputX1{i}; % Extract the sequence
% Assuming each sequence is a 2D matrix where rows are time steps
tempData = [real(tempData), imag(tempData)]; % Combine real and imaginary parts
XTrain{i} = tempData.'; % Transpose to make it [Features, TimeSteps]
end
2) Ensure that the number of sequences in your predictors matches the number of labels in your responses. The error suggests there's a mismatch.
After making the above corrections the error must go away, provided the corrected data preparation aligns the number of observations in predictors and responses.
I hope it helps.