function fxpscale(bd, cmd, proposalSettings)
    % FXPSCALE Automatically scales the fixed point blocks in a model.
    %
    % This script automatically changes the scaling on
    % all Simulink blocks that do not have their Fixed-Point scaling locked.
    % This file uses model information and min-max data obtain from the last simulation run.
    
    %   Copyright 2007-2017 The MathWorks, Inc.
    SimulinkFixedPoint.AutoscalerUtils.doAutoscaleSanityChecks(bd, cmd);
    
    if nargin < 3
        mdl = SimulinkFixedPoint.AutoscalerUtils.getModelForAutoscaling(bd);
        topAppdata = SimulinkFixedPoint.getApplicationData(mdl);
        proposalSettings = topAppdata.AutoscalerProposalSettings;
        proposalSettings.scaleUsingRunName = topAppdata.ScaleUsing;
    end
    
    sysToScaleName = bd.getFullName;
    try
        [refMdls, ~] = SimulinkFixedPoint.AutoscalerUtils.getMdlRefs(sysToScaleName);
    catch failureToFindMdlRefs
        rethrow(failureToFindMdlRefs);
    end
    
    if strcmpi(cmd, 'Collect')
        collectionObj = SimulinkFixedPoint.DataTypingServices.Collection(sysToScaleName, refMdls, proposalSettings);
        collectionObj.execute();
    end

    if strcmpi(cmd, 'Propose')
        collectionObj = SimulinkFixedPoint.DataTypingServices.Collection(sysToScaleName, refMdls, proposalSettings);
        collectionObj.execute();
        proposalObj = SimulinkFixedPoint.DataTypingServices.GroupProposal(sysToScaleName, refMdls, proposalSettings);
        proposalObj.execute();
    end
    
    if strcmpi(cmd, 'Apply')
        applicationObj = SimulinkFixedPoint.DataTypingServices.Application(sysToScaleName, refMdls, proposalSettings);
        applicationObj.execute();
    end
end
