MATLAB (an abbreviation of "matrix laboratory") is a proprietary multi-paradigm programming language and numeric computing environment 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.
As of 2020, MATLAB has more than 4 million users worldwide. MATLAB users come from various backgrounds of engineering, science, and economics.
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 productAlthough 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.Some of the basic functions in MATLAB and their uses are listed below:Function Descriptiondisp() The values or the text printed within single quotes is displayed on the output screenclear To clear all variablesclose all To close all graphics windowclc To clear the command windowexp(x) To compute the exponential value of x to the base eabs(x) To compute the absolute value of xsqrt(x) To compute the square root of xlog(x) To compute the logarithmic value of x to the base elog10(x) To compute the logarithmic value of x to the base 10rem(x, y) To compute the remainder of x/ysin(x) To compute the sine of xcos(x) To compute the cosine of xtan(x) To compute the tangent of xatan2(x, y) To compute the arctangent or inverse of y/xWriting a MATLAB program: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.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 commentVector Operations:Operations such as addition, subtraction, multiplication and division can be done using a single command instead of multiple loopsWe can also extract separate rows and columns by using the colon(:) operator. Consider a matrix A of size 3X3. The following commands can be used to extract rows and columns from Matrix ACommand DescriptionA(:, n) To extract the elements of all rows in column n of the matrixA(m, : ) To extract the elements of all columns in row m of the matrixA(:, m:n) To extract the elements of all rows between columns m and n of the matrixA(m:n, : ) To extract the elements of all columns between rows m and n of the matrixA(p:q, m:n) To extract the elements of rows between p and q and columns between m and n of the matrixA(m, n) To extract the elements of row m and column n