matlab怎么写[1 -1 1 -1 .]向量在做这道题:Make the vector lin =[1 2 ⋯ 20] (the integers from 1 to 20),and then makeevery other value in it negative to get lin =[1 −2 3 −4 ⋯ −20]

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/02 22:23:34
matlab怎么写[1 -1 1 -1 .]向量在做这道题:Make the vector lin =[1 2 ⋯ 20] (the integers from 1 to 20),and then makeevery other value in it negative to get lin =[1 −2 3 −4 ⋯ −20]
xݒN0_$$ic-XyT$IDT.ćЪb`xЉW,, wi[!,N.dEB;^]t4},Gtq(TJ kZɩ` _Hx8 Tb ʊ'<>HcHX0*%2'\\.2H:'R^8F'.`:L>"^GL%ijSs+=C,fsm1 $(, v6x`7 8WH}D/EvKem r(%Ȩ%2jIyj6,uqgO>;

matlab怎么写[1 -1 1 -1 .]向量在做这道题:Make the vector lin =[1 2 ⋯ 20] (the integers from 1 to 20),and then makeevery other value in it negative to get lin =[1 −2 3 −4 ⋯ −20]
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]

matlab怎么写[1 -1 1 -1 .]向量在做这道题:Make the vector lin =[1 2 ⋯ 20] (the integers from 1 to 20),and then makeevery other value in it negative to get lin =[1 −2 3 −4 ⋯ −20]
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