%CDLChannelInfo TR 38.901 CDL channel model information

%   Copyright 2016-2023 The MathWorks, Inc.

%#codegen

function [info,pdp] = CDLChannelInfo(model)
    
    %----------------------------------------------------------------------
    % Delay profile related info
    [infoDP,pdp] = wireless.internal.channelmodels.CDLChannelDelayProfileInfo(model);

    %----------------------------------------------------------------------
    % ClusterAngleSpreads and XPR for nrCDLChannel
    if isfield(model,'AngleSpreads') % nrCDLChannel
        infoASX.ClusterAngleSpreads = model.AngleSpreads; % AngleSpreads for nrCDLChannel
        infoASX.XPR = model.XPR; % XPR for nrCDLChannel
        if ~isscalar(infoASX.XPR)
            infoASX.XPR = NaN; % output NaN when XPR is a matrix
        end
        infoTmp1 = mergeStructs(infoDP,infoASX);
    else %lte3DChannel
        infoTmp1 = infoDP;
    end
    
    %----------------------------------------------------------------------
    % Antenna arrays related info
    infoA = wireless.internal.channelmodels.CDLChannelAntennaArraysInfo(model);
    
    %----------------------------------------------------------------------
    % Channel and filter delay related info
    infoF.ChannelFilterDelay = model.ChannelFilterDelay;
    infoF.MaximumChannelDelay = ceil(max(model.PathDelays*model.SampleRate)) + model.ChannelFilterDelay;

    %----------------------------------------------------------------------
    % Assembly info
    infoTmp2 = mergeStructs(infoTmp1,infoA);
    info = mergeStructs(infoTmp2,infoF);
    
end

function s1 = mergeStructs(s1,s2)
    f = fieldnames(s2);
    for i=1:length(f)
        s1.(f{i}) = s2.(f{i});
    end
end
