Difference between two successive elements in a matrix

10 ビュー (過去 30 日間)
AJA
AJA 2020 年 12 月 6 日
コメント済み: Rik 2020 年 12 月 6 日
For example, I have a 100 x 3 matrix A
A =
[1 0 542
1 5 21
1 10 125
1 15 6245
1 20 2678
1 50 580
1 55 1205
1 60 196
… … ...]
I need to find the difference between successive rows in the second column. For example 5-0=5 for the first two rows of the second column and 10-5=5 for the second and third rows o the second column. If the difference is not 5, I need to store that in a counter. I need to count all the rows with difference of more than 5 per column. How do I do that?
  1 件のコメント
Rik
Rik 2020 年 12 月 6 日
Before you decide to edit this one substantially as well: archive.

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

回答 (1 件)

dpb
dpb 2020 年 12 月 6 日
D=diff(A(:,2));
ix=find(D>5)+1;

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by