フィルターのクリア

I need to create one vector from performing subtraction within another.

1 回表示 (過去 30 日間)
Darreon Schwartz
Darreon Schwartz 2016 年 9 月 18 日
コメント済み: Darreon Schwartz 2016 年 9 月 18 日
I need to take a vector X1 X2 X3 X4 X5 and create a new vector, 1 unit shorter: (X1-X2) (X2-X3) (X3-X4) (X4-X5) and so on. I'm very new to matlab and any help would be appreciated.

採用された回答

Stephen23
Stephen23 2016 年 9 月 18 日
編集済み: Stephen23 2016 年 9 月 18 日
Just negate the output of diff:
-diff(your_vector)
eg
>> vec = [1,8,3,7,2];
>> -diff(vec)
ans =
-7 5 -4 5

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by