function out = ncchain(infiles, varName) % NCCHAIN - Chain time variables from several ncfiles into a single array % % Use as: out = ncchain(infiles, varName) % % Inputs: infiles = a vector of netcdf objects % varName = the name of the variable to chain % Brian Schlining % 02 Mar 2001 n = length(infiles); for i = 1:n infile = infiles(i); varObject{i} = infile{varName}; if isempty(varObject{i}) continue end dimObjects = dim(varObject{i}); % Get the dimensions of the variable of interest dimNames = ncnames(dimObjects) % Get the names of the dimensions timeDim = find(strmatch(lower(dimNames), 'time')); % Locate the time axis srcBuf = cell(1, length(dimObjects)); for i = 1:length(dimObjects) if i == timeDim % concatenate the data else srcBuf{i} = ':' end end end