フィルターのクリア

Subtracting elements in an array

1 回表示 (過去 30 日間)
Nikolas Spiliopoulos
Nikolas Spiliopoulos 2017 年 1 月 21 日
コメント済み: Star Strider 2017 年 1 月 22 日
hi there,
I have an array lets say
A=[10 9 10; 1 2 3; 4 5 6]
How can create an array like this?
B=[10-1 9-2 10-3;10-1-4 9-2-5 10-3-6]
thanks in advance!
Nikolas

採用された回答

Star Strider
Star Strider 2017 年 1 月 21 日
編集済み: Star Strider 2017 年 1 月 21 日
If I understand correctly what you are asking, this will work:
A=[10 9 10; 1 2 3; 4 5 6]
B = cumsum(-A(2:end,:))+A(1,:)
A =
10 9 10
1 2 3
4 5 6
B =
9 7 7
5 2 1
  9 件のコメント
Nikolas Spiliopoulos
Nikolas Spiliopoulos 2017 年 1 月 22 日
ok got it, it works! thanks again mate..!!!
Star Strider
Star Strider 2017 年 1 月 22 日
Our pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by