MATLAB: Using 5-fold cross validation with neural networks

cross-validationk-fold neuralnetworktraining

I am trying to use k-fold with my neural networks to compare them with their 3 way split equivalents. I have a 150×4 dataset and since it is a very small amount I am trying to see whether 5-fold would allow the ANN to give better results since if I understood correctly Matlab will then pass 2 training sets 2 testing and a validation containing the respective number of rows after sorting the data randomly.
I have been going through some code examples however every time I try and implement a different example (from matlab or other websites) I either get an error using horzcat "Dimensions of matrices being concatenated are not consistent." or it doesn't work, which isn't making any sense since all 4 inputs and the output have 150×1 structure. I have tried applying k-fold to the individual columns (imported as a numeric matrix) and also as a collective matrix however all I get in the workspace are a testIdxs, a trainIdxs a and a k and an "Index exceeds matrix dimensions" in the command window
Can anyone explain how this needs to be done or share a link where k-fold is done on a dataset and then passed to a neural network for training?

Best Answer

I just wrote a tutorial in the NEWSGROUP
Hope this helps.
Thank you for formally accepting my answer
Greg