Add 3 to just the odd-index elements

43 次查看(过去 30 天)
And have a question regarding 2. Let x = [2 5 1 6]. b. Add 3 to just the odd-index elements
They give the answer as
b = x(1:2:end) + 3
but that makes a new matrix with just two numbers in it.
Like so: "b =
21 20
"
Is the question or the answer wrong?

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-10-11
编辑:Azzi Abdelmalek 2013-10-11
x = [2 5 1 6]
x(1:2:end)= x(1:2:end) + 3

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by