add an integer x to certain values of a vector

1 次查看(过去 30 天)
for example i have the number 8, and i have a vector[ 1 2 3 4 5]
i need to add 8 to the elements 1-4 of the vector to get the value 18
how would i do this?

采纳的回答

Walter Roberson
Walter Roberson 2012-2-23
8 + sum(YourVector(1:4))

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by