Main Content

frestimateOptions

Options for frequency response estimation

Syntax

options = frestimateOptions
options = frestimateOptions('OptionName',OptionValue)

Description

options = frestimateOptions creates a frequency response estimation options object, options, with default settings. Pass this object to the function frestimate to use these options for frequency response estimation.

options = frestimateOptions('OptionName',OptionValue) creates a frequency response estimation options object options using the options specified by comma-separated name/value pairs.

Input Arguments

'OptionName',OptionValue

Estimation options, specified as comma-separated option name and option value pairs.

Option NameOption Value
'BlocksToHoldConstant'

Block paths of time-varying source blocks to hold constant during frequency response estimation, specified as an array of Simulink.BlockPath objects. To identify time-varying source blocks that can interfere with frequency response estimation, use frest.findSources.

Default: empty

'UseParallel'

Set to 'on' to enable parallel computing for estimations with the frestimate command.

Default: 'off'

'ParallelPathDependencies'

A cell array of character vectors or string array that specifies the path dependencies required to execute the model to estimate. All the workers in the parallel pool must have access to the folders listed in 'ParallelPathDependencies'.

Default: empty

Examples

collapse all

Open model.

mdl = 'scdspeed_ctrlloop';
open_system(mdl)

Convert referenced subsystem to normal mode.

set_param('scdspeed_ctrlloop/Engine Model','SimulationMode','Normal');

Obtain input/output points from the model and create sinestream input signal.

io = getlinio(mdl);
in = frest.Sinestream('Frequency',logspace(1,2,10),'NumPeriods',30,...
              'SettlingPeriods',25);

Identify time-varying sources in the model.

srcblks = frest.findSources(mdl)
srcblks = 
  1x4 BlockPath array with properties:

    SubPath
    isLoadingModel
    isSavingModel

Create option set for estimation and specify the time-varying source blocks.

opts = frestimateOptions('BlocksToHoldConstant',srcblks);

Estimate the frequency response.

[sysest,simout] = frestimate(mdl,io,in,opts);

To demonstrate a dependency on a file that is not in the current working folder, move the model files to a temporary folder and return the path to that folder. The pathdepSetup helper function also adds the temporary folder to the MATLAB® search path.

tempPath = pathdepSetup;

Open the Simulink® model.

mdl = 'scdpathdep';
open_system(mdl)

Obtain the model dependency path.

dirs = frest.findDepend(mdl)
dirs = 1×1 cell array
    {'C:/myTempFiles/tpd02d55f5_8b4c_489e_938c_ea004b9c771d'}

The resulting path is on the local drive C:/.

If you are using remote workers, specify that all workers can access your local drive. For example, this command converts all references to the C drive to an equivalent network address that is accessible to remote workers.

dirs = regexprep(dirs,'C:/','\\\\hostname\\C$\\')

Enable parallel computing and specify the model path dependencies.

options = frestimateOptions(...
    'UseParallel','on',...
    'ParallelPathDependencies',dirs);

You can now use these options for frequency response estimation using parallel computing.

io = getlinio(mdl);
in = frest.Sinestream('SimulationOrder','OneAtATime');
frd = frestimate(mdl,io,in,options);

After estimating the frequency response, you can close the model.

bdclose(mdl)

Return the model files to the current working folder and remove the temporary folder from the path.

pathdepCleanup(tempPath)

Alternatives

You can enable parallel computing for all models with no path dependencies. To do so, in the MATLAB® preferences dialog box, click Simulink® Control Design™. Then, select the Use the parallel pool when you use the "frestimate" command option. This global setting persists from session to session until you change this option.

When you select this option and use the frestimate command, you do not need to provide an frestimateOptions object.

If your model has path dependencies, you must create your own frequency response options object that specifies the path dependencies. Use the ParallelPathDependencies option before beginning the estimation.

Introduced in R2010a