How to add subsequent elements of a vector by a scalar and output the new scalar

2 ビュー (過去 30 日間)
Sean
Sean 2022 年 10 月 13 日
回答済み: Ghazwan 2022 年 10 月 13 日
Say I have vector A with 1 row and a scaler B. I need to create a scalar output that gives A(1,1) + B then A(1,2) + B then A(1,3) + B ... and so on.
For simplicity lets use A = [1 2 3 4 5 6 7 8] and B = 3.
In this example, I would need C = 4, 5, 6, 7, 8, 9, 10, 11 at the coorelating locations. i,e when A = 1 then C = 4, when A = 2 then C = 5, and so
on.

回答 (1 件)

Ghazwan
Ghazwan 2022 年 10 月 13 日
A = [1 2 3 4 5 6 7 8] + 3;

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by