classdef UniformParamSpec < modelpack.UncertainSpec
    %modelpack.UniformParamSpec class
    %   modelpack.UniformParamSpec extends modelpack.UncertainSpec.
    %

    %    modelpack.UniformParamSpec properties:
    %       Description - Property is of type 'ustring'
    %       Name - Property is of type 'string'  (read only)
    %       InitialValue - Property is of type 'MATLAB array'
    %       Known - Property is of type 'MATLAB array'
    %       Minimum - Property is of type 'MATLAB array'
    %       Maximum - Property is of type 'MATLAB array'
    %       TypicalValue - Property is of type 'MATLAB array'
    %       EvaluateAllValues - Property is of type 'bool'
    %       EvaluateNominal - Property is of type 'bool'
    %       EvaluateMinMaxOnly - Property is of type 'bool'
    %
    %    modelpack.UniformParamSpec methods:
    %       setUncertainValues -  method to set the uncertain values for a

    % Copyright 2000-2023 The MathWorks, Inc.

    methods  % constructor block
        function this = UniformParamSpec(ID)
            % UNIFORMPARAMSPEC Constructor for a uniform random parameter spec
            %
            % h = modelpack.UniformParamSpec(parameterID);
            %
            % Inputs:
            %    parameterID a modelpack.ParameterID object.
            %

            % Create object

            % No argument constructor call
            ni = nargin;
            if (ni == 0)
                return
            end

            if (ni < 1) || ~isa(ID, 'modelpack.ParameterID')
                error(message('SLControllib:modelpack:errArgumentType','ID','modelpack.ParameterID'))
            end

            % Set invariant properties
            this.Name    = ID.getFullName;
            this.ID      = ID;
            this.Version = 1.0;
        end  % UniformParamSpec

    end  % constructor block

    methods  % public methods
        function setUncertainValues(this,nVals)
            % SETUNCERTAINVALUES  method to set the uncertain values for a
            % UniformParamSpec object.
            %
            % this.setUncertainValues(nVals)
            %
            % NVALS a scalar double with the number of uncertain values to set
            %

            dim   = this.ID.getDimensions;       %dimension of each uncertain value
            uv    = rand([nVals, dim]);          %[0-1] random variable of correct size
            uset  = cell(nVals,1);
            range = this.Maximum-this.Minimum;

            for ct = 1:nVals
                uset{ct,1} = this.Minimum+range.*reshape(uv(ct,:),dim);
            end

            this.UncertainValues = uset;
        end  % setUncertainValues

    end  % public methods

end  % classdef

% LocalWords:  SETUNCERTAINVALUES Vals NVALS
