You are on page 1of 3

Matlab Basics

Objective:
 Learn how to work with Matlab
 Learn work with Matrix in Matlab
 Using Plot function
Theory

MATLAB (matrix laboratory) is a multi-paradigm numerical computing environment and proprietary


programming language developed by MathWorks. MATLAB allows matrix manipulations, plotting
of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with
programs written in other languages, including C, C++, C#, Java, Fortran and Python.

Although MATLAB is intended primarily for numerical computing.

MATRIX is a rectangular array[1] of numbers, symbols, or expressions, arranged


in rows and columns. For example, the dimensions of the matrix below are 2 × 3 (read "two by three"),
because there are two rows and three columns:

1 5 −13
A=[ ]
20 5 −6

A matrix is a rectangular array of numbers or other mathematical objects for which operations such
as addition and multiplication are defined. Most commonly, a matrix over a field F is a rectangular array of
scalars each of which is a member of F. Most of this article focuses on real and complex matrices, that is,
matrices whose elements are real numbers or complex numbers, respectively. More general types of
entries are discussed below. The numbers, symbols or expressions in the matrix are called its entries or
its elements. The horizontal and vertical lines of entries in a matrix are called rows and columns,
respectively.

MATLAB is an abbreviation for "matrix laboratory." While other programming languages mostly work
with numbers one at a time, MATLAB is designed to operate primarily on whole matrices and arrays.

All MATLAB variables are multidimensional arrays, no matter what type of data. A matrix is a two-
dimensional array often used for linear algebra.

A PLOT is a graphical technique for representing a data set, usually as a graph showing the
relationship between two or more variables. The plot can be drawn by hand or by a mechanical or
electronic plotter. Graphs are a visual representation of the relationship between variables, very
useful for humans who can quickly derive an understanding which would not come from lists of
values. Graphs can also be used to read off the value of an unknown variable plotted as a function

1
of a known one. Graphs of functions are used in mathematics, sciences, engineering, technology,
finance, and other areas

To plot in Matlab we use plot function. plot(X,Y) creates a 2-D line plot of the data in Y versus the
corresponding values in X.

Code and Result


Matrix
A=[1 2 3, 5 3 8, 9 7 2];
B=[3 2 2];
AX=B;
X=A\B;
C=inv(A);

Plot

x=0:pi/10:2*pi;

y1=2*sin(x);
y2=sin(x);
y3=0.3*sin(x);

figure

plot(x,y1,'r--o',x,y2,'o',x,y3,'b');

xlabel('Time');
ylabel('Amplitude');

title('Sine function');

hold on;

2
Feeling and Harvest

Matlab is a very strong program to work with mathematics using a matrix as approach to solving the problems,
with a very good features like plotting. Learning how to use matrix and plotting in Matlab will give you a strong
tool to deal with a wide range of mathematical problems.

You might also like