I am lost on how to make the vector x j = sin(pi(j-1)/10), j = 1,...,21
in matlab.
Also I am trying to make the vector 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.
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:
j = 1:21;
xj = sin(pi*(j-1)/10);
Similarly, to make the vector 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.