首页 > 解决方案 > How are the matrix values calculated in Octave when we divide a scalar with a vector?

问题描述

I am starting to use Octave and I am trying to understand how is the underlying calculation done for dividing a Scalar by vector ?

I am able to understand how ./ is operating to give us the results - dividing 1 by every element of the matrix column. However, I am not able to get my head around how we get the values in the second case ? 1 / (1 + a)

Example :
 g = 1 ./ (1 + a)
g =

   0.50000
   0.25000
   0.20000

>> g = 1 / (1 + a)
g =

   0.044444   0.088889   0.111111

标签: vectorizationoctavescalar

解决方案


当您将 1 除以向量时,它会得到一个向量,当在左侧乘以第一个向量时,该向量会产生 1。从这个意义上说,它是向量的一种“逆”,尽管它只是单向逆。在您的示例中:

>> (1/(1+a))*(1+a)
ans =  1
>> (1+a)*(1/(1+a))
ans =

0.088889   0.177778   0.222222
0.177778   0.355556   0.444444
0.222222   0.444444   0.555556

可以说1/(1+a)是 的左逆1+a。这也可以解释为什么向量的维度会被转置。另一种说法:给定一个向量v,是向量方程1/v的解 ( ) 。ww*v=1


推荐阅读