Introduction To Matlab

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

INTRODUCTION TO MATLAB

MATLAB stands for Matrix Laboratory. MATLAB was written initially to implement a simple
approach to matrix software developed by the LINPACK (Linear system package)
and EISPACK (Eigen system package) projects.

MATLAB is a software package for high-performance mathematical computation, visualization, and


programming environment. It provides an interactive environment with hundreds of built-in functions
for technical computing, graphics, and animations.

MATLAB is a modern programming language environment, and it has refined data structures,
including built-in editing and debugging tools, and supports object-oriented programming.

MATLAB is multi-paradigm. So, it can work with multiple types of programming approaches, such
as Functional, Object-Oriented, and Visual. MATLAB does all the computing based on mathematical
matrices and arrays.

HISTORY OF MATLAB
MATLAB was invented by mathematician and
computer programmer Cleve Moler.  The idea for
MATLAB was based on his 1960s PhD thesis.
Moler became a math professor at the University
of New Mexico and started developing
MATLAB for his students as a hobby. He
developed MATLAB's initial linear algebra
programming in 1967 with his one-time thesis
advisor, George Forsythe.  This was followed
by Fortran code for linear equations in 1971.

In the beginning (before version 1.0) MATLAB was not a programming language; it was a simple
interactive matrix calculator. There were no programs, no toolboxes, no graphics. And
no ODEs or FFTs.

The first early version of MATLAB was completed in the late 1970s.The software was disclosed to
the public for the first time in February 1979 at the Naval Postgraduate School in California.  Early
versions of MATLAB were simple matrix calculators with 71 pre-built functions. At the time,
MATLAB was distributed for free to universities. Moler would leave copies at universities he visited
and the software developed a strong following in the math departments of university campuses.

In the 1980s, Cleve Moler met John N. Little. They decided to reprogram MATLAB in C and market
it for the IBM desktops that were replacing mainframe computers at the time. John Little and
programmer Steve Bangert re-programmed MATLAB in C, created the MATLAB programming
language, and developed features for toolboxes.

1
MATLAB Library comes with a set of many inbuilt functions. These functions mostly perform
mathematical operations like sine, cosine, and tangent. They perform more complex functions too like
finding the inverse and determinant of a matrix, cross product, and dot product

Although MATLAB is encoded in C, C++, and Java, it is a lot easier to implement than these three
languages. For example, unlike the other three, no header files need to be initialised in the beginning
of the document and for declaring a variable, the data type need not be provided. It provides an easier
alternative for vector operations. They can be performed using one command instead of multiple
statements in a for or while loop.

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.
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.

Commands related to matrix in MATLAB:

2
Linear Time Invariant Systems
Linear time-invariant systems (LTI systems) are a class of systems used in signals and systems that
are both linear and time-invariant. Linear systems are systems whose outputs for a linear combination
of inputs are the same as a linear combination of individual responses to those inputs. Time-invariant
systems are systems where the output does not depend on when an input was applied. These properties
make LTI systems easy to represent and understand graphically.

LTI systems are superior to simple state machines for representation because they have more memory.
LTI systems, unlike state machines, have a memory of past states and have the ability to predict the
future. LTI systems are used to predict long-term behaviour in a system. So, they are often used to
model systems like power plants. Another important application of LTI systems is electrical circuits.
These circuits, made up of inductors, transistors, and resistors, are the basis upon which modern
technology is built.

Impulse response of an LTI system


In signal processing, an impulse response is the output of a system when we feed an impulse as the
input signal. A Linear Time Invariant system can be characterized by its impulse response. The step
response of a system is the output of the system when the input is a step, H(t) or H(n)n and all its
initial conditions are zero.

3
QUESTION:
Find the output of an LTI system related by y(n) = x(n+1) + 5x(n) - 7x(n-1) + 4x(n-2).
Find the impulse response of the system.

Code:
n = -10:10;
b = [1 5 -7 4]; % coefficients of x
a = 1; % coefficient of y
h1 = 1*(n==(-1))+5*(n==0)-7*(n==1)+4*(n==2);
[h2,x] = filter(b, a, length(n));
stem(n,h1)
ylabel('h(n)')
xlabel('n')
title('impulse response')

Output:

You might also like