simple multiplication / summation using matlab
1 次查看(过去 30 天)
显示 更早的评论
i want to do some complicate calculations by matlab of following
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
n=0:65119;
x = cos(3.6*n)*sin(3.6*n);
y = x*x
it shows errors however, saying
Error in ==> ex3_1_2 at 3 x = cos(3.6*n)*sin(3.6*n);
what's happening?
2 个评论
采纳的回答
Walter Roberson
2012-10-4
The MATLAB operator "*" is matrix multiplication. Element-by-element multiplication is ".*"
cos(3.6*n) .* sin(3.6*n)
5 个评论
Walter Roberson
2012-10-4
You did not happen to show us the mathematical notation for what you are trying to do.
In MATLAB, 0:65119 is a row vector, 1 x 65120 in length. Matrix multiplication of two row vectors cannot be done: Matrix multiplication (mathematically) requires that the "inner dimensions" must be equal. Matrix multiplication is defined for (1 x 65120) * (65120 x 1) (giving a 1 x 1 result), and is defined for (65120 x 1) * (1 x 65120) (giving a 65120 x 65120 result), but it is not defined for (1 x 65120) * (1 x 65120)
It is mathematically possible to dot-product or cross-product vectors that have the same orientation; we cannot tell whether that is your intention.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!