Change in diff function

4 ビュー (過去 30 日間)
Fatima Rashid
Fatima Rashid 2019 年 7 月 9 日
コメント済み: Guillaume 2019 年 7 月 10 日
Hey, diff function takes difference of successive elements. How to change the function to take difference in a way that we skip successor element and take difference with next element of successor. Eg X(3)-X(1) , X(4)-X(2) , X(5)-X(3) and so on Note: diff of 2d array is being taken.

採用された回答

Guillaume
Guillaume 2019 年 7 月 9 日
You can't change the diff function, but it is trivial to implement your difference:
result = X(3:end) - X(1:end-2)
For a 2D array, you need to apply the indexing to the correct dimension, e.g. for difference between rows:
result = X(3:end, :) - X(1:end-2, :)
  2 件のコメント
Fatima Rashid
Fatima Rashid 2019 年 7 月 9 日
Thankyou, what about if we need to apply same thing on an image.
Guillaume
Guillaume 2019 年 7 月 10 日
An image is a matrix like any other, you can do exactly the same.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by