I occasionally get asked how to interpolate EEMs from different datasets to merge them into one.

**NOTE: Do this at your own risk. If you wish to PARAFAC the resulting merged dataset, watch closely how the model deals with the two halves that you merged by interpolation. **

In the code below, DS1 is the dataset you wish to use as template for wavelengths, DS2 is the one you would like to interpolate to fit to DS1. inter2 interpolates linearly be default but offers different options that may work better. You should inspect the results and make sure it works well. If DS2 has far less datapoints in emission and/or excitation, the interpolation may produce strange results.

The example below starts with two fully imported datasets that passed through checkdataset.

% Preallocation
Xi=nan(DS2.nSample,DS1.nEm,DS1.nEx); % The interpolated EEM of DS(3)
% Interpolation
for n=1:size(Xi,1)
Xi(n,:,:)=interp2(DS2.Ex,DS2.Em',squeeze(DS2.X(n,:,:)),DS1.Ex,DS1.Em');
end

% Overwrite the old data in DS(3)
DS2.X=Xi;
DS2.Ex=DS1.Ex;
DS2.Em=DS1.Em;
DS2.nEx=DS1.nEx;
DS2.nEm=DS1.nEm;

% Make a new combined dataset
new=DS1;
new.X=[DS1.X;DS2.X];
new.nSample=size(new.X,1);
new.filelist=[DS1.filelist;DS2.filelist];
new.i=[1:new.nSample]';
new.Abs=[DS1.Abs;DS2.Abs];