Updated March 14, 2023
Introduction to MATLAB exponent
MATLAB offers us different types of exponent functions that can compute the exponential of an array or matrix. These functions can be used to compute basic exponential, matrix exponential, or exponential integral as per our requirement. In this article, we will learn about 3 exponent functions offered by MATLAB: exp, expint, and expm. With the help of these functions, we can compute the solution when our input is an array, matrix, or a complex number and ‘e’ is raised to this power.
Syntax of exponent function:
- E = exp (I)
- E = expint (I)
- E = expm (I)
Description of the syntax:
- E = exp (I) is used to return the exponential ‘e’ raised to the power (I). For an array, it will compute the exponential of every element
- E = expint (I) is used to return the exponential integral of every element in the input ‘I’
- E = expm (I) is used to compute the matrix exponential for our input matrix ‘I’. Please note that matrix exponential is given by the formula:
expm(I) = EVec * diag (exp (diag (EVal))) / EVec, where EVec represents Eigen Vectors and Eval represents Eigen Values
Examples of Matlab exponent
Let us now understand the code for these exponent functions in MATLAB
Example #1 (exp (I))
In this example, we will find the exponent of an array in MATLAB by using the exp (I) function. Below are the steps to be followed:
- Initialize the array whose exponent we need to compute
- Pass the input array as an argument to the exp function
Code:
I = [2 4 6 2 6]
[Initializing the array whose exponent we need to compute]
E = exp (I)
[Passing the input array as an argument to the exp function]
This is how our input and output will look like in MATLAB:
Input:
Output:
As we can see in the output, the exp function has computed the exponential of every element in our input array ‘I’.
Next, we will learn the use of the expint function
Example #2 (expint (I))
In this example, we will find the integral exponent of an array in MATLAB by using the expint (I) function. Below are the steps to be followed:
- Initialize the array whose integral exponent we need to compute
- Pass the input array as an argument to the expint function
Code:
I = [2 3 5 1 6]
[Initializing the array whose integral exponent we need to compute]
E = expint (I)
[Passing the input array as an argument to the expm function]
This is how our input and output will look like in MATLAB:
Input:
Output:
As we can see in the output, the expint function has computed the integral exponential of every element in our input array ‘I’.
Next, we will learn the use of the expm function
Example #3 (expm (I))
In this example, we will find the matrix exponent of a matrix in MATLAB by using the expm (I) function. Below are the steps to be followed:
- Initialize the matrix whose matrix exponent we need to compute
- Pass the input matrix as an argument to the expm function
Code:
I = [2 3 5; 1 0 3; 2 5 7]
[Initializing the 3 x 3 matrix whose matrix exponent we need to compute]
E = expint (I)
[Passing the input matrix as an argument to the expm function]
This is how our input and output will look like in MATLAB:
Input:
Output:
As we can see in the output, the expm function has computed the matrix exponential of our input matrix ‘I’.
The exponent functions discussed above can also be used to compute the exponential of complex numbers. Let us understand this with an example.
Example #4 (exp (I))
In this example, we will find the exponent of an array of complex numbers in MATLAB by using the exp (I) function. Below are the steps to be followed:
- Initialize the array of complex numbers whose exponent we need to compute
- Pass the input array as an argument to the exp function
Code:
I = [2 + 3i 5 - 1i 4 + 5i]
[Initializing the array of complex numbers whose exponent we need to compute]
E = exp (I)
[Passing the input array as an argument to the exp function]
This is how our input and output will look like in MATLAB:
Input:
Output:
As we can see in the output, the exp function has computed the exponential of every complex element in our input array ‘I’.
Conclusion
- Different forms of Exponent function can be used to compute the exponentials as per our requirement.
- Basic exponential, integral exponential, matrix exponential are the types of exponentials we can compute using the exponent functions.
- The exponential of complex numbers can also be calculated using the exponent functions.
Recommended Articles
This is a guide to Matlab exponent. Here we discuss the 3 exponent functions offered by MATLAB: exp, expint and expm, along with the examples. You may also have a look at the following articles to learn more –