Google Search
Login & Blog Feeds
Blogroll
Recent Comments
- Engineering, Control Systems and Statistics | Blog at ControlTheoryPro.com on Observations on Control System Modeling
- spradlig on MATLAB Pricing (Final Part in the Mathworks is behaving like Microsoft series)
- spradlig on MATLAB Pricing (Final Part in the Mathworks is behaving like Microsoft series)
- PointOnePA on MATLAB Pricing (Final Part in the Mathworks is behaving like Microsoft series)
- spradlig on Observations on Control System Modeling
Archives
- October 2009
- April 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
Categories
16th April 2009
When modeling real-world systems for control it is often necessary to deal with a realistic approximation of the noise and disturbances the system is likely to experience. For satellites with pointing systems this often means that a disturbance PSD is created or measured. This disturbance is modeled as a random process whose energy is described by the PSD. The PSD is applied to a State-Space model which represents the structural characteristics of the system – specifcally the characteristics of the transmission this disturbance energy to various portions of your system.
All of this starts with a PSD so we define a PSD class
classdef psdData
....
end
From here we define our properties, methods and events. Since this will be a stand-alone class for holding and manipulating data, there are no events. So what properties do we need?
- Bare Essentials
- Name: Name the PSD data
- Freq: Vector of Frequencies at which Magnitude data is captured
- Mag: Vector of Magnitudes measured
- RootPSD: Is this a a root PSD – in other words the units are something like rad/rt(Hz) instead of rad^2/Hz?
- Plotting Essentials
- UnitBaseMag: Base unit for magnitude measurements
- UnitBaseFreq: Base unit for frequencies at which magnitude measurements are captured
- PlotFreqUnit: Frequency Units desired on PSD Plot
- TimeUnit: The UnitBaseMag just holds a value like radians or degrees or m or ft. If the measured magnitude is a rate – rad/sec or m/sec then this holds that the TimeUnit is 1/sec
The reason the units are broken up into base and time portion is because we will be including methods to integrate and differentiate the PSD. In my industry rate PSDs are often the easiest to measure. As a result we often get rate PSDs (in rad/sec) but need an angular (position) disturbance PSD so we end up integrating the measured rate PSD. So it only makes sense to incorporate integration and differentiation into our class. I’ll deal with the methods in a later posting
Now that we have a list of properties we need to decide access priviledges. See a full list of Class Property Attributes here.
10th April 2009
I hardly used MATLAB 2008a and never installed 2008b because of the shear amount of time it required to solve all of the stupid little issues with Mathworks new installation procedure. I hate it and they should get rid of it. However, in MATLAB 2008a Mathworks introduced a huge change to their classes.
In some of my work creating classes makes a lot of sense. However, in previous versions building a class was an excrutiatingly slow and painful process requiring the developer to create a multitude of m-files for setting and getting properties, for displaying the data, and other basic infrastructure. In 2008a MATLAB came out with a new way of programming classes which – at least for small, simple classes – greatly reduces development time.
In MATLAB 2008a, many of the infrastructure m-files you used to have to build for classes disappeared. The entire class can be held in a single file if desired. This one file can contain properties, events and methods. For my purposes I usually end up with a few m-files containing helper functions for certain pieces of codes that are required in several places.
Over the course of the next several blog posts I’ll be going through an example of a class I built in about a day. I’ve also found that making tweaks is very easy since there are far fewer files to deal with and many changes made to methods take effect immediate without the need to destroy and recreate the instance of class you are testing.
The example class will be a class for holding and plotting PSD Data. Something very useful for Stochastic controls.
23rd November 2008
What finally worked
I have a quad core machine at my desk so I run multiple MATLAB windows. These multiple windows allowed me to test some distributed computing processes. As a result I set up a script for allowing the multiple windows to run. I was using Stateflow in the model which requires a compile before each run. As a result the model had to be run from a temporary directory.
This temporary directory was the first sign that the function, when distributed, is working. The second sign was when the output file is saved.
Long story short, the batch command worked. The batch command works but only with the PathDependencies and FileDependencies properties set. The function is something like this
jj = batch(‘monte_sim_loop’, ‘matlabpool’, 0, ‘PathDependencies’, {…}, ‘FileDependencies’, {…});
The matlabpool set to 0 is important. I tried to using a matlabpool of 3 for my initial runs. It tied up 4 nodes but only run 1 instance of the sim. Then I created a loop
for ii = 1:15
jj = batch(…
end
The reason that a matlabpool of 3 tied up 4 nodes was that the matlabpool property is for how many additional nodes you want running. It originally appeared to be an overhead function that was created. A coworker discovered the matlabpool command already assumes 1 node and so anything higher than 0 ties up that many extra PCs for the 1 job task. Since I just want my jobs distributed (not parallel) I set the property to 0. When I ran the loop above, 15 computers were tied up and 15 nodes worth of results were produced.
If you know more, please share
I invite anyone and everyone who knows more about how to use the Parallel Computing Toolbox to share. Use the comments to share. Or if you like I welcome guest bloggers.
Thanks
Previous, related, posting
20th November 2008
Monte Carlo Runs
For work I’ve been asked to run a Monte Carlo analysis. The analysis is one where I vary a large set of parameters in a large Simulink simulation. Any given simulation will take between 40 minutes and a few hours. So obivously generating thousands of runs with a single computer would take months.
In the lead up to this analysis I asked a few questions. First, I found a bank of parallel computing resources at work. I asked them if it was possible and the answer was “Yes” with my take away being that it was doable and easy. It may be doable, it is not easy. Second, I went to Mathworks training (on modeling for aerospace system which had a session on parallel computing) and asked some questions about how to run parallel operations. I also left this session thinking it would be easy.
The online help is worthless
When you are running a model of any complexity there are a lot of parameters to set. If you are building models correctly you will be setting these parameters via variables not hard coding. This means that the simulation workspace must have all those variables.
The Mathworks help with regard to the Parallel Toolbox and Simulink simulations is pretty meager. One of the easiest means of distributing the simulation is through the use of the parfor keyword instead of the for keyword. The meager help suggests that simulation must be run from within a function because parfor requires a static workspace and Simulink creates variables in whatever workspace it runs from. So the help suggests using a dummy function as a wrapper for the sim command.
The help forgets to mention that running a simulation from a function’s workspace is simple – once you find that help but finding that help was a little buried. (If you want to know how look up the simset function and the SrcWorkspace and DstWorkspace properties.) I have run several simulations from within a function’s workspace on a single PC. However, doing so from within a dummy function called from a parfor loop doesn’t work like it does from a single PC. And the error messages are obtuse.
Obtuse Error Messages
I spent days attempting to get the simulations distributed to the various nodes. The error messages provided at this stage were reasonably straight forward. However, once the simulation was distributed to the nodes the error became far less useful. The first couple of times there was no obvious error. After digging through a long log file a cowroker found the errors and helped me fix them. That said, I think they were listed as warnings in the log file not errors.
Next Post: What finally appears to have worked
16th October 2008
MEMS Gyro models
MEMS gyroscopes are becoming common in Aerospace systems. They are small, low power sensors accurate in frequency ranges good for Aerospace applications. Often, MEMS gyros are the only sensors commerically available that provides the necessary frequency response, mass, power and environmental.
I’ve found 2 types of MEMS gyro modeling. Both of these modeling types are for the design of the MEMS gyro. A MEMS gyro sensor requires design of some key parameters - resonant frequency, driving frequency, and quality factor. These articles are not on the frequency response of the sensor. The frequency response and noise are the primary items to model for control systems. So these design articles are high fidelity models and information purposes.
Traditional modeling of MEMS Gyros
Traditional design modeling of MEMS gyros often starts with an FEM of the sensor. However, the FEM is often too large for feasible modeling. FEM modeling can be infeasible for memory reasons or simply the length of time it takes to produce results.
The next step in traditional design modeling is to create an equivalent electrical circuit for detailed analysis in various software packages. Again producing results from these equivalent circuit models is time consuming.
Wiki article on Traditional MEMS Gyro modeling
Simplified lumped parameter model for MEMS Gyros
I found a journal article describing a lumped parameter model for MEMS gyroscope design suitable for running in Simulink. The benefit of the Simulink lumped parameter model technique allows for much faster MEMS gyro design results through simple gains and trnsfer function blocks. The results present in the journal article looked encouraging.
Wiki article on Simplified lumped parameter model for MEMS Gyros
More articles coming…
Accurate sensor models are necessary for any good control loop design. So I have a couple more sensor model/design articles coming. After that I will start adding details of MEMS gyros as I find them on the web.
12th October 2008
I’ve written an article on the wiki on what I call controller fusion. I refer to it as controller fusion becuase, like Sensor Fusion, I use filters to blend non-ideal outputs from more than 1 transfer function into 1 output which is closer to the desired output.
For a work proposal on a reaction cancellation mechanism I used a proportional controller for fast response and a PI-Lead controller to drive the steady-state error to 0. In simple sensor fusion the sensor outputs are filtered and then added together to form a better single output. In this form of controller fusion I use filters on the error signal to adjust the gain of the controller in real-time. As a result, PI-Lead output is almost turned off for a step command and the proportional controller output is almost turned off when the system is holding a steady-state value.
I have not had the time to bring this idea to full maturity but I thought it was an interesting enough idea to share.
07th October 2008
New Look Coming Soon…
I recently paid someone to make a real logo for my site. Additionally, I’ve noticed that the site Header on the wiki has gotten very large. So large in fact that the content of the page falls off the bottom. If I was visiting someone else’s site I’d find this very annoying.
So I’ve been working hard to reskin the wiki to incorporate some SEO tricks I’ve learned as well as the new logo. The primary benefit will be to move some the current wiki Header template text to the page header and the left side. When I’m done I hope the skin header will be a little shorter than its current height and the wiki Header template size will no more than half its current height. Check it out as I work on it at the Beta site.
Automatic report generation with MATLAB
For years I’ve had to create reports in Word and PowerPoint. Unlike Excel, there is no nice, simple, function call for placing text, pictures, and tables into a Word or PowerPoint document. As a result I, and many other engineers, have wasted countless hours over the years manually inserting pictures, tables, or boilerplate text into reports.
So I’ve created functions – through trial and error because there is no documentation I can find – to accomplish these tasks. Soon I’ll have a free pdf of the basics. The free pdf will be followed by a pdf for sale. The second pdf will cost about $100. I’ll list out what I’ve discovered (largely through weeks and weeks of trial and error) and include a couple of basic functions.
Soon after the release of these 2 pdfs and freebie automation tools I’ll release a small set of MATLAB automation tools. The functionality these tools will offer is
- Insert Pictures
- Insert Tables
- Insert Text
- Insert Slides into a PowerPoint Slideshow
- Replace pictures
- Replace Table Contents
- Copy template slides from 1 PowerPoint file to another
- …
Lots of Sensor articles Coming Soon
I’ve contacted sensor manufactuerers and gotten lists of data on their sensors. With these lists I’ll be creating articles comparing manufactuerer to manufactuerer, lines within a manufactuerer, and individual sensor articles. Much like a product catalog a lot of the text surrounding the specifications of each sensor would be the same. However, Google will penalize me for having duplicate content if I do that. So I’ll have to work around that.
18th September 2008
MATLAB Pricing
MATLAB is a great tool. I use it every day and have few complaints. However, I’d like to use it for personal purposes. The price of MATLAB makes its use for personal purposes cost prohibitive. As of Sept. 14th, 2008 the prices are
- MATLAB: $1900
- Simulink: $3000
- Control System Toolbox: $1000
- Signal Processing Toolbox: $800
This is the basic MATLAB package I’ve always had as a professional. Sometimes I have other toolboxes but I always have at least these. Can most of us afford $6700 for personal use?
The MATLAB Monopoly
If MATLAB had any real competition, would the price still be $1900 for just MATLAB? There are 2 competitors that I know of and neither is really a true competitor. The first competitor is OCTAVE a free MATLAB like program. In my brief examination of OCTAVE for use on my website I found it to be lacking most of the functionality of MATLAB. The second competitor I come across is SimApp. I’ve been in contact with a marketing person here in Colorado for SimApp and the price I was given was $500. They have several licenses but I haven’t dug around the site to see what license you get for $500. SimApp is a much smaller application with much less to it than MATLAB.
The purpose of SimApp is to offer only what we need most of the time and to do so at a reasonable price. Mathworks offers items in toolboxes for the same purpose – at I assume that’s why. However, their prices aren’t reasonable.
Is there justification for MATLAB’s price?
Like Microsoft, Mathworks is the only game in town and they set whatever price they want. The price is high and I don’t like it but is it justified?
The Mathworks updates MATLAB about twice a year. For the most part it is bug fixes and minor improvements. Very rarely is there serious new functionality included in these updates. For MATLAB 2008a the major upgrade is in Object Oriented programming. The new interface is light years better than the old but the functionality isn’t new.
Most of the improvements I heard of over the last couple of years have involved improved plotting tools. Some tools are new like a GUI interface to allow for interactive regression on the plot. The other plotting improvements are bug fixes in my opinion (i.e. bugs like the aspect ratios not remaining fixed in certain uses of the saveas function). After all these years, they still haven’t gotten the bode plot right in my opinion.
Conclusion
This latest round of installations for MATLAB 2008a really made me and a lot of my coworkers very angry. There was a lot of extra work to get it installed. And the only reason for our having the extra was that Mathworks didn’t do the work themselves. In essence Mathworks let the users do beta testing of the MATLAB 2008a installation process on a full release version. Kind of like every new Microsoft operating system, this program wasn’t ready for general release.
Since many of us who use and love MATLAB have long been cranky about the price for an individual license, there is some latent hostility and strong beliefs about knocking the chip off Mathworks’ shoulder.
MATLAB is a great program and every company has a right to set their own price to maximize profit. That doesn’t mean users have to happy about it. Companies with real competition worry more about irritating their customers. That or they go out of business.
P.S.: 64 bit MATLAB
I have a 64 bit Quad core PC. I installed 64 bit MATLAB on it. However, anything in Simulink that requires a compiler doesn’t work. Mathworks doesn’t ship a compatible compiler. The only compiler compatible with Simulink on a 64 bit installation is a special installation of Microsoft’s Visual Studio 2005 Professional. It seem kind of silly to install a $300 program just for the compiler.
Obviously, Mathworks should have included a compatible compiler. The tech support was very helpful in this but only after I got nasty with them. And the first level tech suggested more than one incorrect fix and this got to be time consuming.