matlab怎么写[1 -1 1 -1 .]向量

问题描述:

matlab怎么写[1 -1 1 -1 .]向量
在做这道题:
Make the vector lin =[1 2 ⋯ 20] (the integers from 1 to 20),and then make
every other value in it negative to get lin =[1 −2 3 −4 ⋯ −20]
1个回答 分类:英语 2014-11-24

问题解答:

我来补答
lin=1:20;
for n=1:length(lin)
lin(n)=lin(n)*(-1).^(n+1)
end
lin
结果为:
Columns 1 through 17
1 -2 3 -4 5 -6 7 -8 9 -10 11 -12 13 -14 15 -16 17
Columns 18 through 20
-18 19 -20
 
 
展开全文阅读
剩余:2000
下一页:铜,及其化合物