MATLAB Examples

A Walkthrough of using the pmap suite

First, the objective here is to find all of the negative real parts of the roots of a given polynomial with parameters. There is no restricition on the number of parameters, but for practical reasons we only consider 2 or 3 parameters. I will release the gui for the visualization of n parameters at some point. If you prefer not to wait, you can email me.


Getting started

The methods used here has been parallelized with the use of a parfor loop so it is a good idea to start a matlabpool.

matlabpool local;
Destroying 1 pre-existing parallel job(s) created by matlabpool that were in the 
finished or failed state.

Starting matlabpool using the 'local' configuration ... connected to 2 labs.

The Examples

I have created several examples in the 'examples' directory. Inside each subdirectory, there is a script , a data file, and an eps image. The only file that is really needed is the script. The data and eps file are published for reference and comparison. You can generate your own data and image from this suite of tools.

ls examples ;
ls examples/ExampleOriginal ;
Example21  Example22  Example431  Example432  ExampleOriginal

ExampleOriginal_Data.mat  ExampleOriginal_img.eps  ExampleOriginal.m

Running an Example

When you run a script, it creates a polynomial with parameters, displays a little bit of information about the example, and creates a structure called pspace. The pspace strucure is just an easy way to define the range of parameters you want to test.

     from ACC2009 and ACC2010 paper
     by Keel et al
This is was the original problem I worked on. It is a fairly simple MIMO system with a memorable shape, so it makes for a good test case.
A good parameter space to check is kp: [-3.5 .5], kd: [-9 2]
    kp: [-3.5000 0.5000]
    kd: [-9 2]

The Suite of Tools

In the 'functions' directory are 4 tools.

  • pmap_generate - generates polynomials and structure
  • pmap_calc - uses strucutre to calculate in parallel
  • pmap_plot - uses results from calc to plot
  • pmap - a wrapper that will run the above three tools
ls functions;
pmap_calc.m  pmap_generate.m  pmap.m  pmap_plot.m

Using the Tools

The easiest way to get started is to use the wrapper function, pmap. Call pmap with the arguments of the parameteric, symbolic polynomial and the parameter space:

Generating the test structure...
Setting kd range : [-9  2].
Setting kp range : [-3.5         0.5].
     Getting orthants and assumptions...  4 orthants found (0.01 s).
     Creating per-orthant vertex polynomials...
          Phase interval 2...created 32 polynomials (20.91 s).

          Phase interval 3...created 32 polynomials (24.32 s).
          Phase interval 1...created 32 polynomials (19.84 s).
          Phase interval 4...created 32 polynomials (20.60 s).
(46.71 s)Done generating test structure (47.06 s)
Using 2 parallel workers.
Using threshold : 16
Chunking... Created 128 chunks (1.11 s).
Performing vertex_compan test... Calculated 6367 stable regions (110.68 s).
ans = 
            assums: {{1x2 cell}  {1x2 cell}  {1x2 cell}  {1x2 cell}}
              date: [1x1 struct]
              dims: {'kd'  'kp'}
        gainmargin: [1 1]
    intervalassums: {4x1 cell}
         intervals: [1 2 3 4]
          orthants: {[2x2 double]  [2x2 double]  [2x2 double]  [2x2 double]}
            params: [1x2 sym]
           Pcompan: {4x4 cell}
       phasemargin: [0 0]
           polyfcn: [function_handle]
               pts: [2x2 double]
             spoly: [1x1 sym]
                 t: [1x1 struct]
        testmethod: 'vertex_compan'
             title: {2x1 cell}
           version: [1x1 struct]
     bisect1method: 'longest'
     bisect2method: 'longest'
             debug: 3
           nChunks: 128
            order1: []
            order2: []
      prune1method: 'none'
      prune2method: 'none'
         threshold: 16
                 n: 2
            prune1: []
                 s: [1x6367 struct]
            prune2: []

Note about the Tools

The tools make use of parameter-value pairs for its arguments. They also expand structures that are passed to them. This is why we can just call pmap(del,pspace) - the pspace structure is expanded in the parsing.