add an integer x to certain values of a vector

1 回表示 (過去 30 日間)
lowcalorie
lowcalorie 2012 年 2 月 23 日
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 Center および File ExchangeElementary Math についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by