Introduction to MATLAB
History
Many engineering and scientific challenges incur the need to organize data in matrices, perform various operations on them, and calculate the solution of a set of equations. The combination of more complex problems and evolving computer power led to the development of a special program for working on matrices called MATLAB (Matrix Laboratory). Work on MATLAB was initiated as far back as in the 1950s but the first real version called Fortran MATLAB was on the market in the early 1970s.1 The success of the early MATLAB releases enabled the founders to start a company in 1984 especially for handling MATLAB called the MathWorks2. Today, numerous university departments and corporations in most parts of the world are using it.
Basics
Everything in MATLAB is centered on the concept of a matrix. Strictly speaking, this is a group of numbers organized in a rectangular m x n collection, where the numbers may represent virtually anything. Basically, MATLAB treats scalars and vectors as special cases of matrices.
Operations
A number of ways to manipulate the data may become necessary, such as:
All of these are readily available in MATLAB. Strong built-in routines avoid loops and make for easier development.
Performance
While MATLAB offers strong built-in routines with fast computation, it lacks the optimization feature that platform specific HPC compilers give. This means that MATLAB code is generally slightly slower than optimized Fortran or C++ code, for example. Table 1 and 2 summarize the performance of MATLAB compared to a few contemporary computing environments for a number of arbitrary problems.
a. Double loop , 5000 x 5000 operations:
Environment |
Computation time / s |
Optimized Fortran |
0.26 |
NumPy |
0.96 |
MATLAB |
2.40 |
Java |
12.6 |
Table 1. Performance for nested loop3
b) Matrix multiplication, 1500 x 1500
Environment |
Computation time / s |
MATLAB |
0.97 |
NumPy |
0.96 |
Optimized Fortran |
2.40 |
Java |
12.6 |
Table 2. Performance for Matrix multiplication3
The tables illustrate how MATLABs’s strength lies in the built-in procedures rather than procedural programming. In Table 1, MATLAB is well behind Fortran and NumPy for a problem in the size of 20-30 million operations. However, Table 2 shows how MATLAB can outperform Fortran when the built-in matrix multiplication function is utilized.
Plotting
MATLAB also features a number of plotting options, in 2D and 3D. Lines can be in different shapes and colors, and data points emphasized in different ways. Plotting and visualizations are some of MATLAB’s great strengths.
References
Are you sure you don't want to upload any files?
Fast tutor response requires as much info as possible.
Decision:
Upload a file
Continue without uploading