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.
So let’s start with a Quick guide of a MATLAB.
Here is the list of contents:
- A Quick introduction to MATLAB
- Commonly used mathematical Calculations
- Users of MATLAB
- How to perform addition in MATLAB
- How to perform Subtraction in MATLAB
- How to perform Multiplication in MATLAB
- How to perform division in MATLAB
- How to perform square root in MATLAB
- How to perform Matrix addition subtraction and multiplication, Transpose and inverse in MATLAB
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:
- Numerical Computation
- Calculus and differential equations
- Linear Algebra and Algebraic Equations
- Non-Linear Functions
- Matrices and arrays
- Data analysis
- Curve fitting
- 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:
- Control systems
- Tests and measurements
- Signal processing and communication
- image and Video Processing
- 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:
For example to add:
A= 2 , 3 ;
B = 3, 4 ;
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 ];
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];
7-How to perform Division in MATLAB:
The simple division in MATLAB uses rdivide command:
rdivide or ./
C= rdivide (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:
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
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 ];
The inverse of Matrix in MATLAB:
Taking inverse is quite simple by typing inv ()
A= [2 3 4 ; 5 6 7 ; 6 7 8];
The result will be shown in vector B.
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.