简体   繁体   English

Matlab d中的复向量

[英]Complex Vectors in Matlab d

I am lost on how to make the vector x j = sin(pi(j-1)/10), j = 1,...,21 in matlab. 我不知道如何在Matlab中使向量x j = sin(pi(j-1)/10), j = 1,...,21

Also I am trying to make the vector x j = 2 -j , j=0,1,...,20. 我也试图使向量x j = 2 -j , j=0,1,...,20.

For the last one I tried which I am trying to get the cumulative sum without a for loop. 对于最后一个尝试,我尝试不使用for循环来获取累加和。

 x = 0:20
 s = cumsum(2^-x)

I know that the should both have relatively similiar answers but I only understand how to make simple vectors and not these complex ones. 我知道都应该有相对类似的答案,但我只了解如何制作简单的向量,而不是这些复杂的向量。

To make the vector x j = sin(pi(j-1)/10), j = 1,...,21 you do exactly that: 为了使向量x j = sin(pi(j-1)/ 10),j = 1,...,21,您可以精确地做到:

j = 1:21;
xj = sin(pi*(j-1)/10);

Similarly, to make the vector x j = 2 -j , j=0,1,...,20: 同样,要使向量x j = 2 -j ,j = 0,1,...,20:

j = 0:20
xj = 2.^-j

Do note the .^ operator. 请注意.^运算符。 You usually want to apply element-wise operators in these cases. 在这些情况下,通常需要应用逐元素运算符。

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

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