You are on page 1of 12

INTRODUCTION TO MATLAB

Matlab or Matrix Laboratory is a high-level programming language consisting of an interactive

environment mainly used for numeric computation, programming, and visualization. It has been

developed by MathWorks. The basic functions of Matlab are plotting of functions and data, the

creation of user interfaces, matrix manipulations. It also provides support for interfacing with other

programming languages in C, C++, Fortran, and Java. Besides, it is also used to analyze data,

create models and applications, and also develop algorithms. Along with all this, introduction to

Matlab also provides numerous built-in functions for mathematical operations involving numerous

calculations, performing numerical methods, generating plots, and a lot of other functions. Matlab

also has a very good scope in the automotive domain using Rapid control Prototyping or RCP used

extensively in medical, automotive, and aerospace domains.

Main components / highlights


In the above section, we studied the introduction to Matlab, so now we’re going to learn the

components of Matlab. Matlab provides a lot of functionalities that can help in computational

mathematics. Below are the most common functions and mathematical calculations used in Matlab

1. Dealing with Matrices and Arrays

2. 2-D and 3-D Plotting and graphics

3. Linear Algebra

4. Algebraic Equations

5. Non-linear Functions

6. Statistics
7. Data Analysis

8. Calculus and Differential Equations

9. Numerical Calculations

10. Integration

11. Transforms

12. Curve Fitting

13. Various other special functions

Characteristics
Matlab is a versatile tool designed for computational mathematics and supports lots of other

operations. Below given are a few of the characteristics that make Matlab an intelligent tool –

1. Matlab contents are a huge library of built-in functions providing support for various

mathematical functions like filtering, optimization, Fourier analysis, linear algebra,

statistics, numerical integration, and solving differential equations.

2. Matlab is a high-level language used for visualization, application development, and

numerical computation.

3. Matlab provides support for creating custom plots and data visualization with its built-in

support for graphics.

4. Matlab also supports an iterative environment helping to design and problem solving along

with iterative exploration.

5. Matlab provides integration support with other languages like C, Java, Microsoft Excel,

and .NET for integrating Matlab-based algorithms with external applications.

6. With its uniquely designed programming interface, Matlab helps its users with

development tools for maximizing performance and improving code maintainability.


7. Matlab also supports building applications with custom graphical interfaces.

Applications of Matlab
As we discussed in the introduction to Matlab, we will now learn about Matlab’s applications

which are as follows: Matlab is widely used in the industry as a tool for mathematical computation

and different streams of studies like physics chemistry, engineering, mathematics, Etc. The various

applications involving Matlab are below –

1. Computational Finance

2. Control systems

3. Signal Processing and communication

4. Test and Measurement

5. Image and video processing

6. Computational biology

Advantages of Matlab
Below are the advantages of Matlab:

1. Matlab is a compiler-independent tool and doesn’t require any compiler to execute like as

required in C, C ++. Codes are written in sentences and executed one by one.

2. Being compiler-independent makes Matlab more efficient and productive.

3. Matlab is a fourth-generation high-level language.

4. Matlab coder is used to converting the code that is written in Matlab to Java, Python, C++,

.NET, etc., making the Matlab language more versatile.

5. Different languages can be used to implement scientific theories, and after building the

library files or .dll files, those can be directly implemented in Matlab using other languages.
6. The inbuilt rich library of Matlab contains a library of the neural network, power system,

communication, fuzzy logic, hydraulics, Simulink, electromagnetics, electrics, etc. Thus,

using this reach library, it is always easy to develop and implement any scientific

simulation. These tools can be controlled by using built-in codes so that any manual

intervention of the control can be avoided in the model.

7. Complex mathematical operations like matrix multiplication and addition can be easily

accomplished in a single code by using Matlab.

8. Matlab also supports loops by using the length of code same or even shorter as compared

to C or C++ in a much convenient way.

9. Matlab also supports the writing of user-defined functions, which are extremely easy to

implement and also can be stored in separate files for future use. This potentially saves a

lot of time writing the same code which is needed for different operations and functions in

regular use.

10. Matlab allows the import and export of data to or from a text or excels file using a single

command which is very useful for analysis of previously recorded data. Matlab allows

storage of data in excel files or .mat files.

11. Data can also be saved in variables with very simple commands, which are easy to use by

storing numbers in a vector or matrix where no use of loops is needed.

12. Matlab also gives a feature to use GUI or graphical user interface using add and drop boxes.

On programming the proper functions of the code by using a graphical user interface, the

code is automatically generated by the program. The compilation of the code is also very

easy to implement, where the program is compiled in Matlab to a standalone application

that can be opened on any system.


13. Matlab offers a huge set of toolboxes and functions, allowing easy solving of CFD or fluid

flow and heat transfer problems very quickly.

14. Matlab also provides REPL – read, evaluate, print, loop or interactive environment to do

mathematical computations and data visualization through graphs.

Disadvantages of Matlab
Below are the disadvantages of Matlab:

1. Cross-compiling of Matlab code to other languages is very difficult and requires deep

Matlab knowledge to deal with errors produced.

2. Matlab is used mainly for scientific research and is not suitable for development activities

that are user-specific.

3. Matlab is an interpreted language; thus, it can be very slow.

4. Poor programming practices can contribute to making Matlab unacceptably slow.

5. Matlab is more expensive. The license is very costly, and users need to buy each and every

module and need to pay for the same.

6. Matlab is not known to create application deployment for installation like the task done by

others which includes the setting of files another executable that copies during installation.
Applied MATLAB
MATLAB Capabilities
Industrial MATLAB
MATLAB INTERFACE

 Command Window:
In this window one must type and immediately execute the statements, as it requires quick
prototyping. These statements cannot be saved. Thus, this is can be used for small, easily
executable programs.
 Editor (Script):
In this window one can execute larger programs with multiple statements, and complex
functions These can be saved and are done with the file extension ‘.m ‘
 Workspace:
In this window the values of the variables that are created in the course of the program (in
the editor) are displayed.
This window displays the exact location(path) of the program file being created.
Writing a MATLAB program:
1. Using Command Window:
Only one statement can be typed and executed at a time. It executes the statement when the
enter key is pressed. This is mostly used for simple calculations.
Note: ans is a default variable created by MATLAB that stores the output of the given
computation.
2. Using Editor:
Multiple lines of code can be written here and only after pressing the run button (or F5) will
the code be executed. It is always a good practice to write clc, clear and close all in the
beginning of the program.
Note: Statements ending with a semicolon will not be displayed in the command window,
however, their values will be displayed in the workspace.
Any statement followed by % in MATLAB is considered as a comment
3. Vector Operations:
Operations such as addition, subtraction, multiplication and division can be done using a
single command instead of multiple loops

SIMULINK

Simulink is a MATLAB-based graphical programming environment for modeling, simulating and


analyzing multidomain dynamical systems. Its primary interface is a graphical block diagramming
tool and a customizable set of block libraries. It offers tight integration with the rest of
the MATLAB environment and can either drive MATLAB or be scripted from it. Simulink is
widely used in automatic control and digital signal processing for multidomain simulation
and model-based design.
Model-Based Design with Simulink
Modeling is a way to create a virtual representation of a real-world system. You can simulate this
virtual representation under a wide range of conditions to see how it behaves.
Modeling and simulation are valuable for testing conditions that are difficult to reproduce with
hardware prototypes alone. This is especially true in the early phase of the design process when
hardware is not yet available. Iterating between modeling and simulation can improve the quality
of the system design early, by reducing the number of errors found later in the design process.
You can automatically generate code from a model and, when software and hardware
implementation requirements are included, create test benches for system verification. Code
generation saves time and prevents the introduction of manually coded errors.
In Model-Based Design, a system model is at the center of the workflow. Model-Based Design
enables fast and cost-effective development of dynamic systems, including control systems, signal
processing systems, and communications systems.
Model-Based Design allows you to:
 Use a common design environment across project teams
 Link designs directly to requirements
 Identify and correct errors continuously by integrating testing with design
 Refine algorithms through multidomain simulation
 Automatically generate embedded software code and documentation
 Develop and reuse test suites

The workflow in this tutorial focuses on fundamental Simulink® tasks as they relate to Model-
Based Design.
 System Definition and Layout — Identify modeling goals, determine components, model
system layout.
 Model and Validate a System — Model and test components, integrate components, test system.
 Design a System in Simulink — Design and test new components.
The first two tasks in this workflow model an existing system and establish the context for
designing a component. The next step in this workflow would be to implement the new component.
You can use rapid prototyping and embedded code generation products, such as Simulink Real-
Time™ and Embedded Coder®, to generate code and use the design with a real, physical system.

You might also like