Info

此问题已关闭。 请重新打开它进行编辑或回答。

matlab matrices

1 次查看(过去 30 天)
Alex
Alex 2011-8-12
关闭: MATLAB Answer Bot 2021-8-20
Guys what is matlab doing in these three situations? If the vector Data equals:
Data =
1.4000 2.9000 4.8000 6.7000 8.9000
Then in this situation: x = (exp(a*2*pi)-cosh(a*b*Data(1)))./sinh(a*b*Data(1))
I understand it is using the first entry of the vector data, and therefore just doing the sum but in this situation:
x = (exp(a*2*pi)-cosh(a*b*Data))/sinh(a*b*Data)
I also just displays one value (0.99999) for x even though Data is a Vector,
then in this situation: x = (exp(a*2*pi)-cosh(a*b*Data))./sinh(a*b*Data)
x is now a vector because of the matrices operator. What i want to know is what is going on behind the . operator. i am trying to calculate this same equation in C programming, but I am not sure what is going on different between having the dot and not having the dot. I know the second scenario is doing something with all the Data values but I dont know what

回答(1 个)

Paulo Silva
Paulo Silva 2011-8-12
with the dot the operations are done element by element, example with multiplication:
[1 2 3].*[4 5 6]=[1*4 2*5 3*6]
without the dot you must do the math with the vector
[1 2 3]*[4 5 6] it's not possible because the size of the second vector, when doing operations without the dot the number of columns of the first vector must be equal to the number of rows of the second
[1 2 3]*[4 5 6]' transposing the second vector and you can now do it, the result is just one value because of the sizes -> 1x3 * 3x1 = 1*1
[1 2 3]*[4 5 6]'=1*4+2*5+3*6=32
  2 个评论
Alex
Alex 2011-8-12
In terms of my aim, I am interested in the product of the second scenario, where
x = (exp(a*2*pi)-cosh(a*b*Data))/sinh(a*b*Data)
i.e no dot product, but a division of vectors and it gives a constant result of 0.9999
so are you saying that it is transposing the part after the division or something?
Paulo Silva
Paulo Silva 2011-8-12
Data=[1.4000 2.9000 4.8000 6.7000 8.9000]
a=1;b=1;
v1=(exp(a*2*pi)-cosh(a*b*Data));
v2=sinh(a*b*Data);
x = (exp(a*2*pi)-cosh(a*b*Data))/sinh(a*b*Data)
x1=v1*(v2/norm(v2)^2)' %Inverse Vector using Geometric Multiplication

此问题已关闭。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by