MATLAB

# How to perform Basic Math functions in MATLAB commonly used functions Quick Guide

In this Quick Tutorial, we will see some of the examples of basic math functions in MATLAB. Before that, there is a quick overview of MATLAB, its uses, benefits and What can be done with a MATLAB.
Here is the list of contents:

### Contents:

1.  A Quick introduction to MATLAB
2.  Commonly used mathematical Calculations
3. Users of MATLAB
4. How to perform addition in MATLAB
5. How to perform Subtraction in MATLAB
6. How to perform Multiplication in MATLAB
7. How to perform division in MATLAB
8. How to perform square root in MATLAB
9. How to perform Matrix addition subtraction and multiplication, Transpose and inverse in MATLAB
10. Conclusion

### 1-Introduction to MATLAB:

MATLAB is developed by MathWorks.A high-level Programming language software used for Numerical computation.Most of the computational math work, algorithms, Complex Engineering problems, Graphs and system design equations can be done with MATLAB.

It also has other great features of designing a control system using it’s Simulink library.

### 2-Commonly Used Mathematical Calculations in MATLAB:

The Commonly used mathematical calculations are:
1. Numerical Computation
2. Calculus and differential equations
3. Integration
4. Linear Algebra and Algebraic Equations
5. Non-Linear Functions
6. Matrices and arrays
7. Statistics
8. Data analysis
9. Transforms
10. Curve fitting
11. 2-D and 3-D graph plotting

### 3-Uses of MATLAB:

As a computational tool MATLAB is widely used in almost all Engineering fields. Other than Engineering MATLAB is also used in physics, Chemistry, and maths.
The applications fields of MATLAB are:
1. Control systems
2. Tests and measurements
3. Signal processing and communication
4. image and Video Processing
5. Computational Finance and Biology

### 4-How to perform Addition in MATLAB:

Performing most of the simple functions are quite similar to C and C++ language:
A= 2 , 3 ;
B = 3, 4 ;
C= A+B;
it’s quite simple..!
For an array we write in matlab as:
A= [ 1 2 ; 3 4];
B= [3 4  ; 5 6 ];
C= A + B adds array A and B and stores the result in C

The semicolon in the center shows that the row has changed.We write columns without any comma’s and To move into the second row the semicolon is used.The semicolon at the end shows the functions is over as we did in the C language.

### 5-How to perform Subtraction in MATLAB:

The Same procedure is used for subtraction:
A=[2 3; 4 5];
B= [5 6 ; 7 8 ];
C= A-B

### 6-How to perform Multiplication in MATLAB:

The element wise multiplication in MATLAB uses the time’s command:
times or .*
A= [2 3 ; 4 5 ];
B= 4 5 ; 6 7];
C=A.*B

### 7-How to perform Division in MATLAB:

The simple division in MATLAB uses rdivide command:
rdivide or ./
C= rdivide (a,b)
C= a./b
c=a./b performs division of each element of array a with each element of array b.

### 8-How to perform Square Root in MATLAB:

Taking square Root is quite simple in MATLAB:
The square root uses the sqrt command:
A=sqrt(X)
it takes the square root of the elements of array X and stores the result in A.

### 9-How to perform Matrix addition subtraction and multiplication, Transpose and inverse in MATLAB

Now comes to the Matrix Part.The matrix addition and subtraction inverse and transpose etc.

#### Matrix Addition and subtraction Multiplication and Division in MATLAB:

There is no special command for addition and subtraction:
The division command uses / or   slash both have same results:
A=[ 1 2 ; 3 4 ; 5 6 ];
B= [3 4 ; 5 6 ; 8 9 ];
C= A+ B
D= A-B
E= A* B
F = A/B
The result will be shown in the matrix form.

#### Transpose of a matrix in MATLAB;

Transpose operation switches rows and columns in a matrix.The command used for transpose in MATLAB is a single ()
A= [2 3 4 ; 4 5 6 ; 7 8 6 ];
B= A’

#### The inverse of Matrix in MATLAB:

Taking inverse is quite simple by typing inv ()
A= [2 3 4 ; 5 6 7 ; 6 7 8];
inv(A)
or
B=inv (A)
The result will be shown in vector B.

### Conclusion:

In this quick Tutorial, we will see some basic concepts of MATLAB. How to perform the basic math functions.We will come up with detail overview of MATLAB with Step by step guide of each and everything in coming Tutorials. Stay connected for further Tutorials.

#### Mak

Mechatronics Engineer-Solution Architect-Entrepreneur-
Crazy about traveling and writing-Being average isn't a choice Never be the same ever-Be simple and Be happy..!!!

MATLAB