Difference between successive rows in a column

3 ビュー (過去 30 日間)
Krishna
Krishna 2022 年 8 月 5 日
編集済み: Fangjun Jiang 2022 年 8 月 5 日
I have a table with 60 columns and 60,000 rows. I want to find the difference of second row and first row of 40th column, then difference between 3rd and 2nd row, 4th and 3rd row, etc. It goes until it reaches he last row. Also, I need to assign those difference values in the 61st column. Please help me with this.

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2022 年 8 月 5 日
編集済み: Fangjun Jiang 2022 年 8 月 5 日
a=magic(6);
b=diff(a(:,4))
b = 5×1
-5 1 -5 -5 1
a(2:end,end+1)=b
a = 6×7
35 1 6 26 19 24 0 3 32 7 21 23 25 -5 31 9 2 22 27 20 1 8 28 33 17 10 15 -5 30 5 34 12 14 16 -5 4 36 29 13 18 11 1

カテゴリ

Find more on Tables in Help Center and File Exchange

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by