How to “Divide the data set”

First divide the data
into calibration and validation data. For example half the samples in each set

Xcal = X(1:2:268,:,:); 
Xval = X(2:2:268,:,:); 
ColorCal = color(1:2:268); 
ColorVal = color(2:2:268);

As these data are spectral
scaling is not per se very relevant. Centering is relevant if it reduces the complexity of the model. In order to center the data find the mean spectrum of the calibration set (e.g., Xcal) and a subtract it from the calibration as well as the test data.

Use the m-file 
nprocess for preoprocessing the data (type help nprocess)
and remember that for the calibration data (dependent as well as independent data)
the mean values are estimated and subtracted whereas for the validation data the mean values are given from the calibration data.