Main Content
Syntax
Description
example
returnsY
= exp(X
)
the exponential ex for
each element in array X
. For complex elements z
= x
+ iy
,
it returns the complex exponential
Use expm
to compute a matrix exponential.
Examples
collapse all
Numeric Representation of e
Calculate the exponential of 1, which is Euler’s number, e.
Euler’s Identity
Euler’s identity is the equality eiπ+1=0.
Compute the value of eiπ.
Plot Exponential Function
Plot y=ex/2 for x
values in the range [-2,10].
X = -2:0.5:10; Y = exp(X/2); plot(X,Y)
Input Arguments
collapse all
X
— Input array
scalar | vector | matrix | multidimensional array | table | timetable
Input array, specified as a scalar, vector, matrix, multidimensional array, table, or
timetable.
Data Types: single
| double
| table
| timetable
Complex Number Support: Yes
Output Arguments
collapse all
Y
— Exponential values
scalar | vector | matrix | multidimensional array | table | timetable
Exponential values, returned as a scalar, vector, matrix, multidimensional array, table, or
timetable.
For real values of X
in the interval (-Inf
, Inf
), Y
is
in the interval (0
,Inf
). For
complex values of X
, Y
is complex.
The data type of Y
is the same as that of X
.
Extended Capabilities
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
This function fully supports tall arrays. For
more information, see Tall Arrays.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For
more information, see Run MATLAB Functions in Thread-Based Environment.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more
information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced before R2006a
expand all
R2023a: Perform calculations directly on tables and timetables
The exp
function can calculate on all variables within a table or
timetable without indexing to access those variables. All variables must have data types
that support the calculation. For more information, see Direct Calculations on Tables and Timetables.
- Trial Software
- Trial Software
- Product Updates
- Product Updates
Main Content
Exponential, logarithm, power, and root functions
In addition to common functions like exp
and log
, MATLAB® has several other related functions to allow flexible numerical calculations.
The expm1
and log1p
functions compensate for numerical round-off errors in small arguments,
while the reallog
, realpow
, and realsqrt
functions restrict the range of these
functions to real numbers. nthroot
calculates roots of any order, while the
specialized functions pow2
and nextpow2
calculate powers of two.
Functions
exp |
Exponential |
expm1 |
Compute exp(X)-1 accurately for smallX |
log |
Natural logarithm |
log10 |
Common logarithm (base 10) |
log1p |
Compute natural logarithm of 1+X accurately for smallX |
log2 |
Base 2 logarithm and floating-point number dissection |
nextpow2 |
Exponent of next higher power of 2 |
nthroot |
Real nth root of real numbers |
pow2 |
Base 2 exponentiation and scaling of floating-point numbers |
reallog |
Natural logarithm for nonnegative real arrays |
realpow |
Array power for real-only output |
realsqrt |
Square root for nonnegative real arrays |
sqrt |
Square root |
Topics
- Powers and Exponentials
This topic shows how to compute matrix powers and exponentials using a variety of methods.
- Graphical Comparison of Exponential Functions
This example shows an interesting graphical approach for discovering whether
e^pi is greater than pi^e.
Синтаксис
Описание
пример
возвращает экспоненциальный e x для каждого элемента в массиве Y
= exp(X
)X
. Для комплексных элементов z
= x
+ iy
, это возвращает комплексный экспоненциал
Используйте expm
, чтобы вычислить матричный экспоненциал.
Примеры
свернуть все
Числовое Представление e
Вычислите экспоненциал 1, который является номером Эйлера, e.
Идентичность Эйлера
Идентичность Эйлера является равенством eiπ+1=0.
Вычислите значение eiπ.
Графическое изображение показательной функции
График y=ex/2 для значений x
в области значений [-2,10].
X = -2:0.5:10; Y = exp(X/2); plot(X,Y)
Входные параметры
свернуть все
X
Входной массив
скаляр | вектор | матрица | многомерный массив
Входной массив, заданный как скалярный, векторный, матричный или многомерный массив.
Типы данных: single | double
Поддержка комплексного числа: Да
Выходные аргументы
свернуть все
Y
Экспоненциальные значения
скаляр | вектор | матрица | многомерный массив
Экспоненциальные значения, возвращенные как скаляр, вектор, матрица или многомерный массив.
Для действительных значений X
в интервале (-Inf
, Inf
), Y
находится в интервале (0
, Inf
). Для комплексных чисел X
Y
является комплексным. Тип данных Y
совпадает с типом данных X
.
Расширенные возможности
“Высокие” массивы
Осуществление вычислений с массивами, которые содержат больше строк, чем помещается в памяти.
Генерация кода C/C++
Генерация кода C и C++ с помощью MATLAB® Coder™.
Массивы графического процессора
Ускорьте код путем работы графического процессора (GPU) с помощью Parallel Computing Toolbox™.
Эта функция полностью поддерживает массивы графического процессора. Для получения дополнительной информации смотрите функции MATLAB Выполнения на графическом процессоре (Parallel Computing Toolbox).
Распределенные массивы
Большие массивы раздела через объединенную память о вашем кластере с помощью Parallel Computing Toolbox™.
Эта функция полностью поддерживает распределенные массивы. Для получения дополнительной информации смотрите функции MATLAB Выполнения с Распределенными Массивами (Parallel Computing Toolbox).
Представлено до R2006a
Introduction to MATLAB Exponential Function
MATLAB has a variety of commands & functions with numerous utilities. This article will focus on understanding a very important MATLAB function called the ‘exponential function’. We use exp(x) to calculate the exponential of a function passed as an argument. We will also understand how we can visually represent the exponential function. The function whose exponential we wish to calculate, is passed as an argument to the ‘exp’ command.
Let’s first refresh our understanding of the exponential function.
Exponential function is a function where the constant is ‘e’ and it is raised to the power of an argument.
It can be represented as f(x) = b(x)
Here ‘b’ represents a real number which is positive
X represent an exponent argument
Exponential functions are functions of a real variable and the growth rate of these functions is directly proportional to the value of the function. The growth rate is actually the derivative of the function.
In the exponential function, the exponent is an independent variable.
Following is a simple example of the exponential function:
F(x) = 2 ^ x
As depicted in the above graph, the exponential function increases rapidly. Let’s take another function:
g(x) =1/2 raised to the power x, which is an example of exponential decay, the function decreases rapidly as x increases.
For f(x) in the previous example, the function doubles every time we add to x. In the exponential decay of the function, the function decreases to half every time we add to x. This is a feature of exponential functions, indicating how fast they grow or decay.
Example of MATLAB Exponential Function
Below are the examples of MATLAB Exponential:
Now we have brushed our understanding of exponential function, let’s understand its use in MATLAB.
Syntax:
exp (X)
y = exp (X) will return the exponential function ‘e’ raised to the power ‘x’ for every element in the array X.
It can also be used for complex elements of the form z = x + iy.
The output will be
e ^ z = e ^ x (sin y + i cos y)
Now we will understand the above syntax with the help of various examples
Types of Exponential Function in MATLAB
Below are the types of the exponential function in Matlab:
1. Exponential of unity
Let’s first compute the exponential of unity (1).
Code:
exp (1)
Output:
2. Exponential of Positive Number
Let us now take exponential of another positive number.
Code:
exp (3)
Output:
3. Exponential of Negative Numbers
The exponential of negative numbers is also possible. For our understanding let’s take the exponential of ‘-3’.
Code:
exp (-3)
Output:
4. Exponential of Fractions
In the above examples, we saw how to take exponential of integers, we can also take exponential of fractions. For our understanding, let’s take fraction ¼ as an example.
Code:
exp (1 / 4)
Output:
5. Exponential of Floating Point Values
We can also calculate the exponential of floating point numbers. Let’s take a floating point value 2.23 for our understanding.
Code:
exp (2.23)
Output:
6. Exponential of Logarithmic Function
We can also calculate the exponential of a logarithmic function. Let’s take value ‘-2’ for our understanding.
Code:
exp (log (-2))
Output:
7. Plotting an Exponential Function
Let us now learn how can we plot an exponential function. A plot is visually more powerful than normal data when we want to analyze the behavior of our function.
Example:
Our function is A = e ^ (x / 3)
Let’s assume the values to be in the range [-3, 20]. This is how our input will look like:
Code:
X = -3 : 0.5 : 20;
A = exp (X / 3);
plot (X, A)
Output:
So, in this article, we learned how to use the exponential function in MATLAB. We can use exp(x) syntax in MATLAB to calculate the exponential of any function which is passed as an argument. We can also plot the functions which we have computed using the ‘plot’ expression, which allows us to visually interpret our function.
Recommended Articles
This is a guide to MATLAB Exponential. Here we discuss the Introduction to MATLAB Exponential and its different Examples as well as its input and output. You can also go through our suggested articles to learn more –
- Introduction to MATLAB Functions
- Top 10 Advantages of Matlab
- What is Switch Statement in Matlab?
- Matlab sphere() | Syntax and Examples
2- Основы работы в Matlab
2.1.Работа в командном окне, арифметические операции, форматы чисел, константы в Матлаб
2.2.Стандартные функции в MATLAB, специальные функции пользователя
2.3.Векторы, поэлементные и матричные операции, вычисление сложных функции от данного вектора,
2.4.Матрицы как двумерные массивы, обработка матриц и операции с матрицами
1
2.1 – Работа в командном окне, арифметические операции, форматы чисел, константы в Матлаб
Основные арифметические операторы, сложение, вычитание, умножение, деление, возведение в степень + – * / ^
Следующие операции можно выполнять в командном окне:
>>x = 2+7 x = 9
>>x = 3*15 x = 45
>>x = 4^4 x = 64
>>x = 100/8 x= 12.5
>>x = (17 – 9) * 6 / 6 x = 8
2
Форматы чисел;
format short |
1.3333 |
0.0000 |
format short e |
1.3333E+000 |
1.2345E-6 |
format long |
1.333333333333338 |
0.000001234500000 |
format long e |
1.333333333333338 E+000 |
1.234500000000000E-006 |
format bank |
1.33 |
0.00 |
>> x=pi |
>> format long e |
x = |
>> x |
3.1416 |
x = |
>> format long |
3.141592653589793e+000 |
>> x |
>> format bank |
x = |
>> x |
3.141592653589793 |
x = |
3.14 |
|
>> format short e |
|
>> x |
|
x = |
|
3.1416e+000 |
3
Константы и переменные в Matlab
>> pi
ans = 3.1416 (какой формат ?)
>> e = exp (1)
e = 2.7183e+000 (Какой формат ?)
Здесь exp( ) встроенная функция, вычисляет экспоненты.
eps − ε = 2.2204e-016 (самое малое число, которое отличает двух чисел друг от друга)
ans − результат последней операции без знака присвивания i, j − мнимая единица ( −1)
inf − машинный символ бесконечности
NaN − неопределенный результат (0/0, ∞/ ∞, 1∞, и т.д.)
Знак процента % используется при вводе комментарий в любом месте в листинге кода, в начале операции или между строками.
4
2.2. Стандартные функции в MATLAB, специальные функции пользователя
Тригонометрические |
Описание функции |
|
Функции |
||
sin(x) / sind(x) |
синус числа х (радиан) / синус числа х (градус) |
|
cos(x) / cosd(x) |
косинус числа х (радиан) / косинус числа х (градус) |
|
tan(x) / tand(x) |
тангенс числа х (радиан) / тангенс числа х (градус) |
|
cot(x) / cotd(x) |
котангенс числа х (радиан) |
/ котангенс числа х (градус) |
sec(x) / secd(x) |
секанс числа х (радиан) / |
секанс числа х (градус) |
csc(x) / cscd(x) |
косеканс числа х (радиан) / косеканс числа х (градус) |
|
asin(x) / asind(x) |
арксинус чилса х (радиан) / арксинус чилса х (градус) |
|
acos(x) / acosd(x) |
арккосинус числа х (радиан) / арккосинус числа х (градус) |
|
atan(x) / atand(x) |
арктангенс числа х (радиан) / арктангенс числа х (градус) |
|
acot(x) / acotd(x) |
арккотангенс числа х (радиан) / арккотангенс числа х |
|
(градус) |
||
asec(x) / asecd(x) |
арксеканс числа х (радиан) |
/ арксеканс числа х (градус) |
acsc(x) / acscd(x) |
арккосеканс числа х (радиан) / арккосеканс числа х |
|
(градус) |
||
5
Гиперболические Функции |
Описание функции |
sinh(x) |
гиперболический синус числа х |
cosh(x) |
гиперболический косинус числа х |
tanh(x) |
гиперболический тангенс числа х |
coth(x) |
гиперболический котангенс числа х |
sech(x) |
гиперболический секанс числа х |
csch(x) |
гиперболический косеканс числа х |
6
Экспоненциальные |
Описание функции |
Функции |
|
exp(x) |
Экспонента числа х |
log(x) |
Натуральный логарифм числа х |
Целочисленные |
Описание функции |
Функции |
|
fix(x) |
Округление числа х до ближайжего целого в сторону нуля |
floor(x) |
Округление числа х до ближайжего целого в сторону -∞ |
ceil(x) |
Округление числа х до ближайжего целого в сторону +∞ |
round(x) |
Обычное округление числа х до ближайжего целого |
rem(x,y) |
Вычисление остатка от деления x на y |
sign(x) |
Сигнум-функция числа х |
7
Другие Функции |
Описание функции |
|
sqrt(x) |
(square root of x) |
Корень квадратной из числа х |
abs(x) |
(absolute of x) |
Модуль числа х |
log10(x) |
Десятичный логарифм от числа х |
|
log2(x) |
Логарифм по основанию два от числа х |
|
pow2(x) |
Возведение двойки в степень х |
|
gcd(x) |
(greatest common |
Наибольший общий делитель чисел x и y |
divisor) |
||
lcm(x) |
(least common |
Наименьшее общее кратное чисел x и y |
multiple) |
||
rats(x) |
Представление числа х в виде рациональной дроби |
|
factorial(x) |
Вычисление факториала от х |
|
primes(x) |
Генерация простых чисел, не превосходящих |
|
аргумента x |
||
reallog(x) |
ln(x) натуральный логарифм от х |
|
realsqrt(x) |
корень квадратный |
|
8
Замечание о тригонометрических функциях
>>sin(30) ans =
-0.99
>>Sin(pi()*30/180) ans =
0.50
>> sind(30) ans =
0.50
Неправильно (Вычисляется sin(30) в радианах)
правильно
правильно
9
^ возведение в степень |
функция внутри функции |
10
Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #