# DADiSP SPL vs. MATLAB

## A MATLAB alternative? Here’s a brief comparison for those of you who aren’t afraid to explore alternatives…

If you have found this web page, you might be familiar with the MATLAB (1) software from the MathWorks or one of the free clones. This page focuses on the similarities and differences between MATLAB and our alternative, DADiSP.

**Emerging Academic Powerhouse**

The introduction of the Student Edition of DADiSP (a free download for all academic users, by the way) has caused quite a stir at universities and academic institutions around the world. Over the last few years, DSP Development has licensed DADiSP formally to dozens of top universities and training institutes, but the Student Edition program has put DADiSP into the hands of tens of thousands of students and academics to use for research or teaching.

**Technical Computing Tools**

For MATLAB users, one of the more interesting features of DADiSP is a comprehensive data series processing language called **SPL**. Many students and instructors who are familiar with MATLAB and similar products have asked us what makes SPL different. Here’s the scoop…

Although DADiSP and MATLAB are both software tools designed for a technical audience, the products differ considerably in how they meet the demanding data analysis needs of scientists and engineers.

**Matrix Based M Files**

MATLAB is a matrix-based programming language. In fact, MATLAB stands for “MATrix LABoratory” and was originally developed to provide easier programming access to specialized matrix processing routines. MATLAB consists primarily of a command interpreter and a variety of sub-routines that reside in ASCII files known as M files. Typically, the MATLAB user types out expressions or writes small M files to analyze data and generate graphics.

**Engineering Spreadsheet**

DADiSP, on the other hand, is a full-featured data analysis and visualization environment designed around a more generalized data construct called a **data series**. A DADiSP series can represent anything — from a time domain radar signal to a medical image — and includes important attributes about the data. The product’s highly graphical user interface features interrelated “live” graphical windows, manipulated by simple pull-down menus, dialog boxes and point-and-click operation. Graphs are automatic and dynamic. By working in this powerful and familiar environment, the DADiSP user avoids the many perils of programming.

**DADiSP – Language Included**

In short, MATLAB is essentially an interpreted programming environment, somewhat analogous to Visual Basic with technical data analysis capability. DADiSP is more like a spreadsheet, a non-programming core methodology that includes a programming language, similiar to the combination of Excel and Visual Basic.

**SPL**

The ultimate design goal of DADiSP is to allow the user to focus on the problem at hand and not the code in the debugger. However, for those who wish to customize DADiSP or add special processing capability, DADiSP provides a robust series processing language called SPL. SPL is based on the very popular C/C++ language and sports a C/C++ like syntax. As a result, SPL routines have a clean and familiar style about them. Because MATLAB was originally developed in FORTRAN and later rewritten in C, MATLAB programs generally have a less consistent, “mixed breed” feel, often combining FORTRAN and C coding styles.

Although each language has its own approach and advantages, it is fairly easy to convert routines from one to the other. For example, here are two routines that perform numerical quadrature based on the trapezoidal rule — one written in MATLAB and the other in DADiSP SPL:

**Similar…**

Besides non-functional formatting differences, it is clear that the examples above are quite similar. The main differences here are the single line comment character (// verses % ) and the “for” loop syntax. SPL uses C/C++ style initialisation and increment constructs where MATLAB employs a specialized vector-like syntax. Like C/C++, the SPL function uses the return statement to return a value. By comparison, the return value is part of the function declaration in MATLAB. Although one could argue which language is “better” or clearer overall, the SPL routine is understood very easily by those familiar with C/C++.

An example that illustrates further differences between SPL and MATLAB, consider a routine to remove a linear trend from a series or table as found in the MATLAB M file toolbox:

**Yet Different**

Both SPL and MATLAB are free-form and the examples above show the typical formatting styles of each language. The comment block after the function declaration in a M file is displayed when the user types `help detrend`

. SPL displays the free-form text between the `#if @HELP_DETREND`

and `#endif block`

. This block can be placed anywhere within the SPL file.

`detrend`

removes the least squares line from a series or table. The function also has an optional argument to specify that only the mean value should be removed. This optional argument is detected in MATLAB by counting the number of input arguments with `nargin`

. SPL uses the C/C++ like `argc`

to indicate the number of input parameters.

**Matrix vs Series Based Solution**

Because MATLAB is matrix-based and series are stored in row form, row vectors must be transposed into columns. In fact, operators such as * and / actually perform matrix multiplication and inversion. Because SPL is **series-based**, row transpositions are not required and mathematical operators work in the way you would expect. SPL includes the explicit operators `*^`

and `^`

to multiply and solve matrices.

If the optional argument is set to 1, the mean value of each column is removed by forming a table of the mean values and subtracting it from the data. MATLAB forms the table by creating a matrix of all ones and performing a matrix multiply. SPL simply subtracts the mean value of each column from the corresponding column.

The linear trend is removed by forming a least squares line. Again, MATLAB resorts to matrix operations where SPL uses the `linreg`

function.

Although both routines accomplish the same goal, MATLAB approaches the problem from a matrix point of view, where SPL offers a **series-based** solution. Each approach has its advantages, but for problems that involve single or multi-column data series, SPL can result in clearer, more direct code.

**M File Memory Limitations**

All arrays in MATLAB are limited by the amount of physical memory. Because MATLAB relies on the operating system’s general purpose implementation of virtual memory, if an array size exceeds the available memory, calculations produce errors or grind to a halt if a memory page is swapped to disk.

**Virtual Series Management**

SPL employs a optimized method called virtual series management. Each series and each column of an array is limited only by available disk space. If the series size exceeds available memory, SPL automatically uses hard disk storage. Because virtual series management is optimized for series processing, this method is much faster and more robust than general purpose operating system page swapping. The size of a series kept in memory is adjustible, allowing users to optimize processing based on system memory. With SPL, the memory footprint of large data series is small enough to bypass slow operating system page swapping, but computation is fast due to virtual data handling designed specifically for series processing. Thus, SPL is ideally suited for manipulating any number of very large data series.

**More M File Issues**

Because of the mixed heritage of the MATLAB language, several potentially confusing ambiguities persist. For example, the MATLAB * operator actually performs a matrix multiply. A common expression like:

would perform matrix multiplication if a and b are arrays or a standard multiply if either variable is a scalar. A careful reading of the code is required to establish the specific meaning of this simple expression.

SPL preserves the standard meaning of * and introduces the *^ operator for explicit matrix multiplication. Thus,

is always a standard multiplication whereas

is always a matrix multiplication. The intent of either expression is immediately obvious.

Further, the MATLAB expression:

could refer to element *x* of array *f* or function *f* called with argument *x*. Again, a careful reading of the code is required to disambiguate the two possible meanings.

In SPL as well as C/C++,

is always an array reference. The intent is immediately clear and consistent with the C/C++ family of modern programming languages.

**C/C++ Style Syntax**

In fact, SPL borrows so much of its syntax from C/C++ that many C/C++ programs can be loaded directly as SPL routines! For example, SPL supports C/C++ operators such as ++, –, +=, -=, /=, *= %=, ==, !=, >>, <<, >>=, <<=, ||, && and scalar pointers. Looping and iteration constructs such as `for, while, do while, if, else, switch, goto`

work exactly as they do in C/C++. Array construction also mimics the C/C++ syntax. SPL also includes a full C/C++ like preprocessor: `#if, #ifdef, #elif, #endif, #include, #define, #undef`

.

**Useful Constructs**

But SPL also borrows some good ideas from MATLAB. Matrix operators such as matrix multiply `*^`

, divide `^`

and transpose ‘ are supported. Powerful array addressing constructs such range specifiers `1..10`

, array assignments `A[1..10] = 5`

, multiple return values `(a, b) = f(x)`

, automatic loading of SPL routines and built-in help syntax are provided.

A simple table gives a brief summary of the operators and syntax supported by MATLAB, C/C++ and SPL.

**Convert M Files to SPL**

Finally, if you need to convert your M files into SPL routines, the MathWorks offers a MATLAB-to-C conversion utility. Because SPL is so similar to C/C++, you can also use this utility as a great shortcut for converting M files into SPL functions for use in DADiSP.

#### Hier geht es weiter

Wir können Ihnen dieses Produkt zur Zeit leider nicht anbieten.

Bitte kontaktieren Sie uns für weitere Informationen. Wir beraten und unterstützen Sie gerne.

### Sie möchten kaufen?

### Ausgewählte Downloads

#### Was sagen unsere Kunden über uns?

Good tutor genuinely interested in student’s needs. This course provided all I needed and more.

GS, Great Dunmow, UKI am impressed by the level of support your company provides, and the list of software you offer looks very good indeed.

MQ, Edinburgh, UKYour web page is simply brilliant. Congratulations!

CF, Kirknewton, UKI found the training to be hugely beneficial. The delivery was clear, concise, energetic and good humoured. Definitely a good skill based introduction to EndNote, while the notes given on the day will provide a most useful refresher of what was covered.

LS, Tullamore, Ireland### Adept Produkte

Zur Zeit ist es uns leider nicht möglich die folgenden Produkte anzubieten. Wir arbeiten jedoch daran Ihnen ein möglichst vielfältiges Produktsortiment zur Verfügung zu stellen. Bitte kontaktieren Sie uns wenn Sie Fragen oder Anregungen haben.