Make the vector lin=[1 2 3 ⋯ 20] (the integers from 1 to 20), and then make every other value in it negative to get lin=[1 −2 3 −4 ⋯ −20] . what is the MATLAB code?

33 次查看(过去 30 天)
lin=[1:20]
then?

采纳的回答

Matt J
Matt J 2015-7-11
lin(2:2:end)=-lin(2:2:end)

更多回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2015-7-11
编辑:Azzi Abdelmalek 2015-7-11

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by