There isn't a time vector explicitly stored in the 3D array; each slice(*) in the array is associated with the corresponding time in ordinal order, but the array contains only the coordinate data in each plane.
You couldn't actually include the datetime time vector explicitly into the 3D array anyway because of the different data classes (datetime versus double).
It's probably just as simple to leave as is and just use the vector of times as a lookup into the slices of the 3D array wanted.
(*) If my supposition is correct that sss is the 2D salinity array, I'd probably organize the 3D array as planes where time is the 3rd dimension by putting the variable subscript in the last position as
instead. To me at least, it's easier to visualize although the other way is just a slice along a colum index.
Alternatively, you could recast the data into a timetable where each row is a 2D cell array of coordinates.
After the fact with a set of random data had at hand in my workspace from a previous Answer demo, to create a timetable is something like
salinity=rand(10,5,10);
ttSalinity=timetable(t20.Time(1:10),squeeze(mat2cell(salinity,10,5,ones(10,1))), ...
'VariableNames',{'Salinity'});
t20 is another table that happened to have a Time variable in it to save creating a new time vector.
The
squeeze(mat2cell(salinity,10,5,ones(10,1)));
converts the 3D array into a 2D cell array of the same number of rows as the height of the table; IOW each time step contains the 2D salinity data for that time as a cell array. It can't be a regular 2D array because the variables in a timetable must have the same number of rows as the number of times.
For the data at hand here, the above leads to:
ttSalinity =
10×1 timetable
Time Salinity
____________________ _____________
27-Oct-2020 13:35:46 {10×5 double}
27-Oct-2020 13:36:46 {10×5 double}
27-Oct-2020 13:37:46 {10×5 double}
27-Oct-2020 13:38:46 {10×5 double}
27-Oct-2020 13:39:46 {10×5 double}
27-Oct-2020 13:40:46 {10×5 double}
27-Oct-2020 13:41:46 {10×5 double}
27-Oct-2020 13:42:46 {10×5 double}
27-Oct-2020 13:43:46 {10×5 double}
27-Oct-2020 13:44:46 {10×5 double}
>>
Let's see, for your variables above this would look something like --
salinity=cell(Nfiles,1);
times=zeros(Nfiles,1);
for i = 1:Nfiles
disp(['Processing: ' ncfiles(i).name])
times(i)=ncread(ncfiles(i).name, 'time');
salinity{i}=ncread(ncfiles(i).name, 'SSS');
end
cortime=datetime(1950,1,1)+times;
ttSalinity=timetable(times,salinity,'VariableNames',{'Salinity'});
where I avoided the complexity of the squeeze operation by saving as a cell array on reading.