subtracting arrays from each other

2 ビュー (過去 30 日間)
C.G.
C.G. 2023 年 9 月 14 日
回答済み: Dyuman Joshi 2023 年 9 月 14 日
I have 2 arrays. I want to subtract b from a, but starting at the second element of b eg. 16-14, 24-20 etc.
The result should be: 2 4 13 7 5.
a = [16 24 30 27 30 35];
b = [6 14 20 17 20 25];

回答 (1 件)

Dyuman Joshi
Dyuman Joshi 2023 年 9 月 14 日
a = [16 24 30 27 30 35];
b = [6 14 20 17 20 25];
c = a(1:end-1) - b(2:end)
c = 1×5
2 4 13 7 5

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by