function dimensions = util_resolve_dimensions (dimensionData, modelH)
%

%   Copyright 2021-2023 The MathWorks, Inc.
%  This function ensures the value of dimensions is a numeric value. 
% Possible inputs : 
% dimensionData -> Already a number. No action required. 
%               -> Simulink.Parameter. Return param.Value
%               -> Symbolic size ( Name of a Simulink.Parameter). 
%                  Resolve the parameter and return the value. 
%                  
if isnumeric(dimensionData)
    dimensions = double(dimensionData);
    return;
else
    if isa(dimensionData, 'Simulink.Parameter')
        dimensions = double(dimensionData.Value);
        return;
    end

    % HACK: When the parameters are MATLAB expressions, there are additional ascii
    % codes added to the expressions.the below code filters such characters 
    if ischar(dimensionData)
        dimensionData(double(dimensionData) < 32)=[];
    end
    % Assumption :
    % The dimensionData is a character input and is a
    % Simulink.Parameter (symbolic size).
    % As of R2021b, symbolic sizes can only be defined in the global
    % workspace and is not context dependent.
    %
    % When we support model workspaces, use slResolve to resolve
    % the parameter value.
    % dimensions = double(slResolve(dimensionData, context));
    dimensions = resolveInGlobalScope(modelH, dimensionData);
    return;
end
% Should not reach here. Unknown case.
% Consider asserting.
dimensions = double(dimensionData);

end
