The most time consuming operation during frequency response estimation is the simulation of your Simulink® model. You can try to speed up the estimation using any of the following ways:
The time it takes to perform frequency response estimation depends on the simulation stop time.
To obtain the simulation stop time, in the Linear Analysis tool, in the Linear Analysis Workspace, select the input signal. The simulation time will be displayed in the Variable Preview.
To obtain the simulation stop time from the input signal using MATLAB® Code:
tfinal = getSimulationTime(input)
input is the input signal. The simulation
tfinal, serves as an indicator of the
frequency response estimation duration.
You can reduce the simulation time by modifying your signal properties.
Decrease the number of periods per frequency,
You model must be at steady state to achieve accurate frequency response estimation. Reducing the number of periods might not excite your model long enough to reach steady state.
Decrease the signal sample time,
The frequency resolution of the estimated response depends
on the number of samples
For information about modifying input signals, see Modify Estimation Input Signals.
You can try to speed up frequency response estimation by specifying the Rapid Accelerator or Accelerator mode in Simulink.
For more information, see What Is Acceleration? in the Simulink documentation.
You can try to speed up frequency response estimation using parallel computing in the following situations:
Your model has multiple inputs.
Your single-input model uses a sinestream input signal,
where the sinestream
SimulationOrder property has
For information on setting this option, see the
frest.Sinestream reference page.
In these situations, frequency response estimation performs multiple simulations. If you have installed the Parallel Computing Toolbox™ software, you can run these multiple simulations in parallel on multiple MATLAB sessions (pool of MATLAB workers).
For more information about using parallel computing, see Speeding Up Estimation Using Parallel Computing.
You can use parallel computing to speed up a frequency response
estimation that performs multiple simulations. You can use parallel
computing with the Linear Analysis Tool and
When you perform frequency response estimation using parallel computing,
the software uses the available parallel pool. If no parallel pool
is available and Automatically create a parallel pool is
selected in your Parallel Computing Toolbox preferences, then the
software starts a parallel pool using the settings in those preferences.
You can configure the software to automatically detect model dependencies and temporarily add them to the parallel pool workers. However, to ensure that workers are able to access the undetected file and path dependencies, create a cluster profile that specifies the same. The parallel pool used to optimize the model must be associated with this cluster profile. For information regarding creating a cluster profile, see Create and Modify Cluster Profiles in the Parallel Computing Toolbox documentation.
To manually open a parallel pool that uses a specific cluster profile, use:
MyProfile is the name of a cluster profile.
After you configure your parallel computing settings, as described in Configuring MATLAB for Parallel Computing, you can estimate the frequency response of a Simulink model using the Linear Analysis Tool.
In the Linear Analysis Tool, in the Estimation tab, click More Options.
This action opens the Options for frequency response estimation dialog box.
In the Parallel Options tab, select the Use the parallel pool during estimation check box.
(Optional) Click Add path dependency.
The Browse For Folder dialog box opens. Navigate and select the directory to add to the model path dependencies.
Tip Alternatively, manually specify the paths in the Model path dependencies list. You can specify the paths separated with a new line.
(Optional) Click Sync path dependencies from model.
This action finds the model path dependencies in your Simulink model and adds them to the Model path dependencies list box.
After you configure your parallel computing settings, as described in Configuring MATLAB for Parallel Computing, you can estimate the frequency response of a Simulink model.
Find the paths to files that your Simulink model requires to run, called path dependencies.
dirs = frest.findDepend(model)
dirs is a cell array of character vectors
containing path dependencies, such as referenced models, data files,
For more information about this command, see the
frest.findDepend reference page.
(Optional) Check that
all path dependencies. Append any missing paths to
dirs = vertcat(dirs,'\\hostname\C$\matlab\work')
(Optional) Check that all workers have access to the
If any of the paths resides on your local drive, 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 all workers:
dirs = regexprep(dirs,'C:/','\\\\hostname\\C$\\')
Enable parallel computing and specify model path dependencies
by creating an
options object using the
options = frestimateOptions('UseParallel','on','ParallelPathDependencies',dirs)
Tip To enable parallel computing for all estimations, select the global preference Use the parallel pool when you use the "frestimate" command check box in the MATLAB preferences. If your model has path dependencies, you must create your own frequency response options object that specifies the path dependencies before beginning estimation.
Estimate the frequency response:
[sysest,simout] = frestimate('model',io,input,options)
For an example of using parallel computing to speed up estimation, see Speeding Up Frequency Response Estimation Using Parallel Computing.
Frequency response estimation terminates when the simulation data exceed available memory. Insufficient memory occurs in the following situations:
Your model performs data logging during a long simulation. A sinestream input signal with four periods at a frequency of 1e-3 rad/s runs a Simulink simulation for 25,000 s. If you are logging signals using To Workspace blocks, this length of simulation time might cause memory problems.
A model with an output point discrete sample time of 1e-8 s that simulates at 5-Hz frequency (0.2 s of simulation per period), results in million samples of data per period. Typically, this amount of data requires over 300 MB of storage.
To avoid memory issues while estimating frequency response:
Disable any signal logging in your Simulink model.
To learn how you can identify which model components log signals and disable signal logging, see Signal Logging.
Try one or more of the actions listed in the following sections:
Repeat the estimation.
To avoid memory issues, try one or more of the actions listed in the following table, as appropriate for your model type.
|Models with fast discrete sample time specified at output point|
Insert a Rate Transition block at the output point to lower the sample rate, which decreases the amount of logged data. Move the linearization output point to the output of the Rate Transition block before you estimate. Ensure that the location of the original output point does not have aliasing as a result of rate conversion.
|Models with multiple input and output points (MIMO models)|
To avoid memory issues, try one or more of the actions listed in the following table, as appropriate for your input signal type.
|Input Signal Type||Action|
Create separate input signals that divide up the swept
frequency range of the original signal into smaller sections using
|Random||Decrease the number of samples in the random input signal by