简体   繁体   English

在MATLAB中如何获取矩阵的指数?

[英]How is it possible to take an exponential of a matrix in MATLAB?

I have a MATLAB code which I have to convert to C language. 我有一个MATLAB代码,必须将其转换为C语言。 According to the MATLAB code, 根据MATLAB代码,

n1 = 11; x1 = randn(2,n1) + repmat([-1 1]’,1,n1);
w = [0 0]’; 

here acccording to my calculation, the output of 根据我的计算,这里的输出

w’*x1

will be a 1x3 matrix, that is a row vector as far as I know. 据我所知,它将是一个1x3的矩阵,即行向量。

Then what will be the output of the following code, 然后,以下代码的输出是什么,

z = exp(repmat(b,1,n1)+w’*x1);

where repmat() also creates a 1xn1 matrix (I'm not sure about this, figured it out from manual). repmat()还会创建一个1xn1矩阵(对此我不确定,可以从手册中找到)。 My understanding is that addition of two 1x3 matrices will not give a scalar. 我的理解是将两个1x3矩阵相加不会得到标量。

How is an exponential is taken here? 这里如何取指数? Can exponential be applied to a matrix? 指数可以应用于矩阵吗?

Like many MATLAB functions, the exp function operates element-wise when applied to arrays. 像许多MATLAB函数一样, exp函数在应用于数组时按元素进行操作。 For further details, please refer to the documentation . 有关更多详细信息,请参阅文档

Yes, you can apply exponentation to a matrix. 是的,您可以将指数应用于矩阵。 From the Wikipedia article: Matrix exponential 摘自Wikipedia文章: 矩阵指数

Let X be an n×n real or complex matrix. 令X为n×n实数或复数矩阵。 The exponential of X, denoted by e X or exp(X), is the n×n matrix given by the power series X的指数,由e X或exp(X)表示,是幂级数给出的n×n矩阵

e^X = Sum(k=0, infinity) 1/k! * X^k 

As @John Bartholomew pointed though, this is not what the exp() of Matlab does. 正如@John Bartholomew指出的那样,这不是Matlab的exp()所做的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM