# Three months in - and so much more still to discover

*Felix Grant* tries to summarise the wealth of features and functions of MathWorks' latest mammoth upgrade

*'How can one person describe a world? One may indeed use a small pencil to describe a large circle, but if the circle is so large that one cannot make out the curve of it even from the top of a tower, why then the pencil will wear out before it has fairly begun its task. How many tones can one voice take? How can I describe even a single rock, and which rock should I describe?'*

Ursula K. Le Guin, *The First Report of the Shipwrecked Foreigner*

Some products are small enough to cover adequately in the space of a general review. Some upgrades offer modest or even marginal change, allowing a detailed exploration of the enhancement. A new release of the MathWorks' product family CD falls into neither of these categories. Release 13 is huge and its changes extensive. In the three months since I installed this leviathan, I can't claim to have used more than a tiny fraction of its capacity, nor to have more than sampled its developments from the previous version. To cover even that limited operational experience would take a thick book, and I'd not get it written before the next revision was upon me. So, this will be a fast recce across the surface, with quick side trips here and there to visit landmarks which are of particular note, or of which I have local knowledge. There's also a brief aerial outline view of the changes (see 'What's New?', below).

To start at the beginning, quite apart from explicit development, there has been some rearrangement of the furniture or, as The MathWorks describes it, 'product restructuring'. Under this heading come: renaming of a product; changed relationships of one product to others; splitting the functions of one product between one or more others (or vice versa); and so on. The previously separate C/C++ maths and graphics libraries, for example, have been absorbed into the Matlab Compiler. The developer's kit for Texas Instruments digital signal processing, on the other hand, has split into two separate products, which between them embrace and expand the previous feature set. When the dust clears, there are two main routes ahead: Matlab and Simulink. Matlab is the flagship product, so let's take that path first.

The first big idea along this road is speed. Release 13 brings part-one of a phased, long-term goal to match the speed of generic third generation languages such as C. Performance acceleration, which speeds up the processing of M-file functions and scripts, is the first milestone (M-files are Matlab's executable text files). Acceleration is most prominent in settings which make intensive use of self-contained loop constructs with no M-file function calls, which process at a rate comparable to vectorised equivalents - vectorisation being the replacement, for example, of FOR_x=a:b ...x=x+)...END with Matlab's more compact x=a:):b).

The obvious assumption is that vectorised code will run faster still under acceleration, but it doesn't work that way in practice; acceleration of these loop constructs seems to be through an internal optimisation to something akin to vectorised form. The gain is not, therefore, in straightforward contexts like tabulation, but in non-trivial cases where scope for manual vectorisation of the code is less than clear. I went through a fairly convoluted aquifer model, written by a colleague some years ago, vectorising every construct I could see, and obtained a noticeable improvement in run time, when run under the current, accelerated regime. The difference was still significant as the software picked up what I had missed.

The MathWorks declares performance acceleration to be a 'work in progress', and there are as yet a number of things that can interfere with it. As mentioned above, external calls are one source of friction; even if the called entity is accelerated, the call process itself is not, and the resulting overhead hits overall speed. You pay, too, for sloppy data typing or array shaping, since acceleration is halted during inline changes of existing variables. Broadly speaking, the caveats boil down, as always, to 'think ahead'. Equally important is bearing in mind what does not (as yet) benefit from acceleration: arrays of order greater than three, for example (I have found significant benefit in breaking up my n-dimensional models into 2D and 3D components).

Commitment to execution speed over the long haul is only one of several signals that The MathWorks is looking to distance its products from ivory tower associations, and to place them squarely in the commercial and industrial applications arena. This makes sense, and plays to their strengths. The symbolic math toolbox, for instance, is useful but peripheral to Matlab's core identity as a computational tool; and it is one of the few that has not been extended in this release. This concern for the wider marketplace is supported by several 'front end' changes. GUI design is eased and smoothed, for instance, with small improvements like toolbar button access to the GUI editor, easy editing of tab order, optional export of a GUI to a single file, and provision of GUI templates as a starting point.

The GUI design enhancements are symptoms of more general attention to the development environment, which is a world away from the old look of three releases or so ago. The big new arrival is the graphical Profiler, which will radically change your approach to file performance tuning. Smaller progressions in this area range from details like a new toolbar button and 'check for updates' option, up to use of a JVM on three major platforms. A lot of individually small changes (autosave, line column and current function display, internet-enabled file system operations, 'find' dialogue, incremental search, and so on) add up to a considerable productivity gain overall. The array editor (which takes significantly larger structures than before) now behaves like a spreadsheet (well, sort of!) and exchanges data with Microsoft Excel, which is a real bonus. Continuing the MS Office rapprochement, there is also now notebook support for Office 2000 and XP versions of MS Word (although a surprising number of science users out there will mourn the discontinuation of Word 95 support).

I could go on at some length and with great enthusiasm, but Matlab is not the only product in the upgrade and the end of the page looms. I will, therefore, bypass not only the wealth of other goodies, but also the extensively refashioned collection of toolboxes (though I've made a quick pass through Statistics as an example - see box) and move on to the other big hitter in the pack: Simulink. Here we find many of the same concerns as Matlab, including the bid for greater commercial and industrial focus. As with Matlab, there are new or improved editing tools (look-up tables and masks), enhanced approaches to optimisation of structure, presentational polish (annotation at last offers use of symbols and the Greek alphabet), and so on. Support for fixed-point arithmetic is welcome, and new blocks join the reorganised library. New tools include an enhanced Coverage Settings dialogue box for the Model Coverage Tool, and performance improvements to the Graphical Merge Tool. These improvements are supported by a new Simulink report generator, which extracts documentation blocks into a report, expands Scope Snapshot component use, and extends its fetch in other ways. The former power system blockset has been renamed SimPowerSystems, as a part of a unified physical modelling approach embracing other blocksets and developed capability. Two dimensional array output to (and input from) Stateflow is part of a similar set of developments in that direction as well.

Enough; I've barely scratched the surface, but what do you expect in two thousand words on one of the biggest packages in the applied mathematics landscape? I hear the editor's distant but increasingly emphatic cries that both my time and my word count are up, so I'll leave you here with your 'Mathworks Tour' t-shirt and a recommendation that you go and investigate further for yourself, in those areas which most concern your needs but which I have probably bypassed completely. I doubt that you'll be disappointed.

## The statistics tool box

While valuing the whole package, and finding valuable tools wherever I look, like all users I find some aspects of particular interest. The statistics toolbox is the one which I have explored most fully, with new features or enhancements embracing descriptives, multivariate measures, cluster and factor analyses, multidimensional scaling and Procrustes methods, canonical correlations, discriminant analysis, non-linear regression models, classification and regression trees, probability distributions, and DoE. Taking on statistical work in a generic package, when there are dedicated software tools available for the purpose, is not something that everyone wants to do; I don't pretend that it is my own choice in most circumstances. Nevertheless, in the right context there can be distinct advantages, which outweigh the loss of convenience and the steep learning curve.

Picking more or less at whim, since there's not space for full detail, even on this one corner of the product, designed experiments includes designs of full factorial, fractional factorial, response surface and D-optimal types. D-optimal is, in many ways, the most interesting of these; it is, for a start, the one which most vitally depends upon the computationally intensive methods that such products make available. The computation, involving as it does the minimisation of a matrix determinant, is of course a natural for this software; no surprise, then, that the implementation provided is fast and lean. There are four functions: 'cordexch' and 'rowexch', which provide alternative optimisation algorithms for a given model spec; 'daugment' to optimise choice of added runs; and 'covary' for designs from specified covariates. I have run a number of comparison trials, applying these tools to live industrial and agricultural studies where I already had other software in use; the results always matched, and sometimes improved upon, those from dedicated packages or components, though the investment in user effort and learning curve is naturally greater.

The n-dimensional cluster analysis function 'kmeans' is another that is well-suited to matrix array treatment. It returns a vector of indices indicating observation assignment, allows five different distance measures, and minimises the distance sum iteratively; detailed control is through input parameters. My favourite application of this one has, so far, been a whimsical one in conjunction with the provided distributions. Prediction of fossil concentrations for a field trip paid off to a degree of accuracy which consolidates my reputation on the primary school pal¾ontological circuit if nowhere else! (A word to any teachers, parents or grandparents out there in need of a similar street cred boost: the 'magic' function in Matlab, while unconnected with statistics, also goes down well with this audience and takes very little work.) The range of distributions covers most needs. All the usual suspects are there, including some less-often-seen variants (such as noncentral F, t & chi-square, hypergeometric and negative binomial), along with commercial and industrial application regulars such as Weibull.

I won't go on; the whole unit is capable and robust, with significantly useful progress from previous releases. If your statistical analyses are part of a larger, bulk data-handling context, particularly if they are of clearly defined type or out of the ordinary, and are often reused, then this toolbox is a valuable and solid asset.

## What's new?

- Aerospace Blockset, providing system and subsystem reference models and utilities for aerospace contexts.
- COM Builder 1.0, which extends the existing Matlab compiler to automatic conversion of applications into COM objects.
- Curve Fitting Toolbox which, through a graphical user interface, facilitates access to curve fitting functions from pre-processing through to management.
- Embedded Target for Motorola's MPC555, which transfers Real-Time Workshop Embedded Coder code to the microcontroller.
- Embedded Target for TI C6000 DSP Platform, designed to accelerate creation, validation, and deployment of device specific DSP software.
- GUI-based Matlab Excel Builder allows use of Matlab models and functions within Excel worksheets.
- Model-Based Calibration Toolbox, which harnesses Matlab and Simulink to problems requiring powertrain systems calibration.
- SimMechanics (version 1.1 - a significant advance on the previously web-downloadable v.1.0) for modelling of mechanical components and their motion, without need for derivation of the underlying mathematical equations.

Includes environmental specifications, calculation components and representation models.

**New features are found in:**

- Communications Blockset 2.5
- Communications Toolbox 2.1
- Control System Toolbox 5.2
- Data Acquisition Toolbox 2.2
- DSP Blockset 5.0
- Excel Link 2.0
- Filter Design Toolbox 2.2
- Financial Derivatives Toolbox 2.0
- Financial Time Series Toolbox 2.0
- Fixed-Point Blockset 4.0
- Image Processing Toolbox 3.2
- Instrument Control Toolbox 1.2
- Mapping Toolbox 1.3
- Matlab 6.5
- Matlab Compiler 3.0
- Matlab Report Generator 1.3
- Optimization Toolbox 2.2
- Real-Time Workshop 5.0
- Real-Time Workshop Embedded Coder 3.0
- Requirements Management Interface1.0.4
- Signal Processing Toolbox 6.0
- SimPowerSystems (formerly Simulink Powers Systems Blockset)
- Simulink Performance Tools 1.2
- Simulink Report Generator 1.3
- Spline Toolbox 3.1.1
- Stateflow Coder 5.0
- Statistics Toolbox 4.0
- Virtual Reality Toolbox 3.0
- Wavelet Toolbox 2.2
- xPC Target 2.0