 # MATLAB for Computer Science

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:

• Transposition
• Inverse if possible
• Multiplication
• Eigenvalue / Eigenvector calculation
• LU factorization
• Diagonalization

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

1. Moler, C.: The Origins of MATLAB, http://se.mathworks.com/company/newsletters/articles/the-origins-of-matlab.html
2. The Mathworks, mathworks.com
3. Kouatchou, J.: Comparing Python, NumPy, Matlab, Fortran etc.

#### To fulfill our tutoring mission of online education, our college homework help and online tutoring centers are standing by 24/7, ready to assist college students who need homework help with all aspects of MATLAB for computer science. Our computer science tutors can help with all your projects, large or small, and we challenge you to find better online MATLAB for computer science tutoring anywhere.

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

We couldn't find that subject.
Please select the best match from the list below.
For faster response, you may skip assigning directly to a tutor to receive the first tutor available.
That tutor may not be available for several hours. Please try another tutor if you're in a hurry.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

• 1
• 2
• 3

## Latest News  