%

% Copyright 2017 The MathWorks, Inc.
function tseries = fillDimensions(tseries, signalData, splitDims)
    scalar = isscalar(splitDims(1).dims);
    for col = 1:size(splitDims, 2)
        % the 'real' calls in this function are needed because fixed point
        % does not remove 0i from values when indexing
        dims = num2cell(splitDims(col).dims);
        iscomplex = splitDims(col).complex;
        if scalar
            if iscomplex
                tseries.Data(:, dims{:}) = complex(real(tseries.Data(:, dims{:})), real(signalData(:, col)));
            else
                tseries.Data(:, dims{:}) = signalData(:, col);
            end
        else
            if iscomplex
                dataSize = size(tseries.Data(dims{:}, :));
                tseries.Data(dims{:}, :) = ...
                    complex(real(tseries.Data(dims{:}, :)), reshape(real(signalData(:, col)), dataSize));
            else
                tseries.Data(dims{:}, :) = signalData(:, col);
            end
        end
    end
end
