Documentation |
On this page… |
---|
When working with state-space models, proper scaling is important for accurate computations. A state-space model is well scaled when the following conditions exist:
The entries of the A, B, and C matrices are homogenous in magnitude.
The model characteristics are insensitive to small perturbations in A, B, and C (in comparison to their norms).
Working with poorly scaled models can cause your model a severe loss of accuracy and puzzling results. An example of a poorly scaled model is a dynamic system with two states in the state vector that have units of light years and millimeters. Such disparate units may introduce both very large and very small entries into the A matrix. Over the course of computations, this mix of small and large entries in the matrix could destroy important characteristics of the model and lead to incorrect results.
For more information on the harmful affects of a poorly scaled model, see Scaling Models to Maximize AccuracyScaling Models to Maximize Accuracy.
You can avoid scaling issues altogether by carefully selecting units to reduce the spread between small and large coefficients.
In general, you do not have to perform your own scaling when using the Control System Toolbox™ software. The algorithms automatically scale your model to prevent loss of accuracy. The automated scaling chooses a frequency range to maximize accuracy based on the dominant dynamics of the model.
In most cases, automated scaling provides high accuracy without your intervention. For some models with dynamics spanning a wide frequency range, however, it is impossible to achieve good accuracy at all frequencies and some tradeoff of accuracy in different frequency bands is necessary. In such cases, a warning alerts you of potential inaccuracies. If you receive this warning, evaluate the tradeoffs and consider manually adjusting the frequency interval where you most need high accuracy. For information on how to manually scale your model, see Manually Scaling Your Model.
Note: For models with satisfactory scaling, you can bypass automated scaling in the Control System Toolbox software. To do so, set the Scaled property of your state-space model to 1 (true). For information on how to set this property, see the set reference page. |
If automatic scaling produces a warning, you can use the prescale command to manually scale your model and adjust the frequency interval where you most need high accuracy.
The prescale command includes a Scaling Tool GUI, which you can use to visualize accuracy tradeoffs and to adjust the frequency interval where this accuracy is maximized.
To scale your model using the Scaling Tool GUI, you perform the following steps:
Specifying the Frequency Axis Limits in the Scaling Tool GUI
Specifying the Frequency Band for Maximum Accuracy in the Scaling Tool GUI
For an example of using the Scaling Tool GUI on a real model, see Scaling Models to Maximize AccuracyScaling Models to Maximize Accuracy.
For more information about scaling models from the command line, see the prescale reference page.
To open the Scaling Tool GUI for a state-space model named sys, type
prescale(sys)
The Scaling Tool GUI resembles one shown in the following figure.
The Scaling Tool GUI contains the following plots:
The Frequency Response Gain plot helps you determine the frequency band over which you want to maximize scaling.
For SISO systems, this plot shows the gain of your model. For MIMO systems, the plot shows the principle gain (largest singular value) of your model.
The Frequency Response Accuracy plot allows you to view the accuracy tradeoffs for your model when maximizing accuracy in a particular frequency bands.
This plot shows the following information:
Relative accuracy of the response of the original unscaled model in red
Relative accuracy of the response of the scaled model in blue
Best achievable accuracy when using independent scaling at each frequency in brown
When you compute some model characteristics, such as the frequency response or the system zeros, the software produces the exact answer for some perturbation of the model you specified. The relative accuracy is a measure of the worst-case relative gap between the frequency response of the original and perturbed models. The perturbation accounts for rounding errors during calculation. Any relative accuracy value greater than 1 implies poor accuracy.
You can change the limits of the plot axis to view a particular frequency band of interest in the Scaling Tool GUI. To view a particular frequency band, specify the band in the Show response in the frequency band fields.
This action updates the frequency axis of the Scaling tool to show the specified frequency band.
To adjust the frequency band where you want maximum accuracy, set a new frequency band in the Maximize accuracy in the frequency band fields. You can visualize accuracy tradeoffs by trying out different frequency bands and viewing the resulting relative accuracy across the frequency band of interest.
Note: You can use the Frequency Response Gain plot, which plots the gain of your model, to view the dynamics in your model to help determine the frequency band to maximize accuracy. |
Each time you specify a new frequency band, the Frequency Response Accuracy plot updates with the result of the new scaling. Compare the Scaled curve (blue) to the Pointwise Optimal curve (brown) to determine where the new scaling is nearly optimal and where you need more accuracy.
When you find a good scaling for your model, save the scaled model as follows:
Click Save Scaling.
This action opens the Save to Workspace dialog box.
In the Save to Workspace dialog box, verify that any of the following items you want to save are selected, and specify variable names for these items.
Scaled model
Scaling information, including:
Scaling factors
Frequencies used to test accuracy
Relative accuracy at each test frequency
For details about the scaling information, see the prescale reference page.
Click OK.
This action sets the State-Space (@ss) object Scaled property of your model to true. When you set this property to True, the Control System Toolbox algorithms skip the automated scaling of the model.