SysFreq Class Methods

From ControlTheoryPro.com

Jump to: navigation, search
Symbol.gif
SysFreq Class Methods
Green carrot left.gif
sysFreq Class Example sysFreq Class Properties
Green carrot.jpg
In order to prevent spam, users must register before they can edit or create articles.



1 Introduction to sysFreq Class Methods

In Stochastic Controls there are essentially two parts to a frequency domain analysis. First, the disturbance and noise PSDs causing system error. Second, the system response. The system response is typically represented using a transfer function or state-space model.

In order to do a frequency domain analysis you must construct a frequency domain model (using transfer functions or state-space equations) to represent the system components. These components typically include

  • the plant or system to be controlled,
  • the feedback sensors, and
  • the controller or compensator.

These component models must then be connected to form the

  • open loop,
  • closed loop, and
  • disturbance rejection system models.

Then a standard disturbance PSD is applied to disturbance rejection model in order to determine residual error based on the disturbance at the plant's output. The influence of the noise PSD must be determined using the closed loop model. The 2 results are then RSS'd together determine the residual system error. This is fairly straight forward (if a little tedious) for simple SISO systems.

Even for simple SISO systems there are a few implementation issues to be aware of:

  1. The frequency vector of the PSD must be in the same units as the frequency vector of the system model.
  2. The elements of both the PSD and system model frequency vectors must be identical and the vectors must be the same size.
  3. The system model magnitude must be a raw magnitude for system response (to PSD) calculation - not in dB.
  4. MATLAB's bode command requires all frequency vector arguments be in rad/sec not Hz.

There are other implementation issues as well as these. All of the implementation issues are fiarly simple and straight forward to correct. However, it gets tedious fixing these issues for every analysis of every system since most real world systems are MIMO not SISO. Often the MIMO can be broken up into multiple decoupled SISO systems but then you have to add code or calls to helper function for each of these SISO models generated form the original MIMO.

Methods for handling implementation issues:

  1. Issue: PSD & LTI system frequency vectors must have the same units --> Solution: both [psdData Methods|psdData] and sysFreq assume the frequency vector is in Hz and automatically do the conversions to rad/sec when necessary.
  2. Issue: The frequency vector elements for the PSD and System model must be identical --> Solution: the sysFreq forces the system model magnitude response to be at the PSD's frequency values by calling the bode command with the PSD's frequency vector.
  3. Issue: System model magnitude must be in a raw magnitude --> Solution: the getReponse method automatically returns the magnitude in a vector of raw magntudes.
  4. Isuue: MATLAB's bode command requires rad/sec --> Solution: unit conversion between rad/sec and Hz is automaticaly handled in the getResponse method (assuming the UnitBaseFreq property is set to the correct units).

2 sysFreq Class Methods

The sysFreq Class object uses 3 types of methods attributes:

  1. Public: Methods the user can call
  2. Private: Methods only other sysFreq methods can call

Private methods are only available to other methods and are not discussed.

2.1 Display of the sysFreq Class Methods

Let's sysFreq Class Instantiation class object:

 >> a = sysFreq(sys);

where sys is any valid LTI object except FRD. (FRDs require special handling and a limited set of the methods may work but none have not been tested.)

Then the displayed Methods and values are:

 >> methods(a)
         Methods for class sysFreq:
           addlistener  ge                isvalid     plot
           delete         get               le            psdResponse
           eq             getResponse   lt            set
           findobj        getdisp         ne           setdisp
           findprop      gt                notify       sysFreq

2.1.1 sysFreq Method: Instantiation

Basic Examples:

 >> a = sysFreq(sys);
 >> a = sysFreq(sys, freqVec);

where

  • sys: the system model (an LTI object)
  • freqVec: a vector of frequencies that the system should be examined at, this vector can be many elements or just 2 (a minimum and maximum frequency) and is assumed to be in Hz.

2.1.2 sysFreq Method: getResponse

One of the most common pieces of data needed is the system response at a given set of frequencies. This method automatically converts the input frequency vector to the rad/sec (if necessary) and uses MATLAB's bode command to get magnitude and phase data from the system model.

MATLAB's bode command returns the magnitude and phase values in a matrix with 3 dimensions. For SISO systems we only need a vector so the getReponse method returns a vector of raw magnitudes. MATLAB's bode command returns the phase in degrees so the getReponse method also returns the phase in degrees.

Examples:

 >> [mag, phs, freqVec] = getReponse(a);
 >> [mag, phs] = getReponse(a, freqVec);
 >> [mag, phs] = getReponse(a, freqVec, units);

where the inputs are

  • a: the sysFreq object to be examined,
  • freqVec (as an input argument): the frequency values at which the bode command should be performed, assumed to be in the same units as a.UnitBaseFreq, and
  • units: the units of freqVec should they need to be specified (valid values are 'rad/sec' and 'Hz').

The outputs are:

  • mag: raw magnitude in vector form from MATLAB's bode command,
  • phs: phase (in degrees) in vector form from MATLAB's bode command,
  • freqVec (as an output argument): if no frequency vector is provided to the bode command then the object's (sys) freqVec is used by default.

Both the freqVec and units input arguments are optional.

2.1.3 sysFreq Method: psdResponse

From a Stochastic controls perspective the most useful method is the psdResponse method. In this method a PSD is multiplied times the system to obtain a system response to the PSD. The specifics of the response are seen in the following equation

LaTeX: S_{YY}\left(\omega\right)=G*\left(\omega\right)G\left(\omega\right)S_{XX}\left(\omega\right)=\left | G\left(\omega\right) \right |^{2}S_{XX}\left(\omega\right)


where

  • LaTeX: S_{XX}\left(\omega\right) is the one-sided input PSD in LaTeX: \frac{magnitude^{2}}{Hz},
  • LaTeX: G\left(\omega\right) is the frequency response function of the system and,
  • LaTeX: S_{YY}\left(\omega\right) is the one-sided output PSD or auto power spectral density function.

Note that some texts will state that this is only valid for random processes which are staiontary. Other texts suggest stationary and ergodic while still others state weakly stationary processes. Some text do not distinguish between strictly and weakly stationary. From practice, the rule of thimb is if the PSD of the input process is the same from hour to hour and day to day then the input PSD can be used and hte above equation is good enough.

2.1.4 sysFreq Methods: plot

There are a few standard plots that I like to see when checking out a model or presenting a model to colleagues. I've included these plots in this method. Specifically they are:

  1. Magnitude and Phase (2 subplot in a single column)
  2. Magnitude Only
  3. Phase Only

The basic call to the plot method is as follows:

 >> [h] = plot([], a);

where

  • h is the returned figure handle for the plot on a new figure (same as gcf), and
  • a is the sysFreq object to plot.

Multiple sysFreq objects can be plotted on a single plot with a call like this:

 >> [h] = plot([], a, b, c, ...);

where

  • h is, again, the returned figure handle for the plot on a new figure (same as gcf), and
  • a, b, c, ... are the sysFreq objects to plot.

If you wish to re-use a old figure then you can replace that figure with this one by passing in the figure handle like this:

 >>plot(h, a);

where

  • h is the desired figure handle for the plot on a old figure, and
  • a is the sysFreq object to plot.

The default plot is for Magnitude and Phase plots (a PlotType property value of 1) to change that call the plot method like this:

 >> [h] = plot([], a, b, c, ..., 'PlotType', 2);
 >> [h] = plot([], a, b, c, ..., 'PlotType', 3);

where setting PlotType to 2 will plot Magnitude Only and setting it to 3 will plot Phase Only.

Notes on varargin

  • The first inputs, after the figure handle, must be sysFreq objects. Not a cell array of objects but simply the objects themselves - plot([], a, b, c, 'Title', 'My Plot', ...);
  • After the last sysFreq object is entered then Property/Value pairs can be entered. Any valid axes property can be used just as if you had plotted the figure from the command prompt. Additional Property/Value pairs are:
Table 2: Property/Value Pairs for plot & plotTime Methods
Parameters Value

'plottype', 'type'

1, 2, or 3 - 1 = Magnitude and Phase, 2 = Magnitude only, 3 = Phase Only --> Defaults to 1

'units', 'unit', 'plotfrequnit'

'Hz' or 'rad/sec'

'freqvec'

Vector of any valid frequencies in the units specified in the UnitBaseFreq property or passed in using the UnitBaseFreq varargin for this method.

'unitbasefreq', 'freqvecunit'

'Hz' or 'rad/sec'

'name', 'title'

Sets the top axis Title property as well and the figure's Name property to the string provided

'legend'

Provides a legend with the names of the PSDs at the designated location, see MATLAB's help on legends for possible location strings


Examples:

plot([], a, 'Title', 'My Sys')
plot([], a, 'Title', 'My Sys', 'PlotType', 2)
plot([], a, 'Title', 'My Sys', 'PlotType', 3)
plot([], a, b, 'Title', 'My 2 Systems', 'legend', 'SouthWest')

3 Notes

  • This class requires the Controls System Toolbox