I want to get the difference between the present number and the previous number for 1000 set of data from the plot.

3 ビュー (過去 30 日間)
For example,
I have considered 10 random values from the set of 1000 values
X-axis values are as given a = [ -9.658 -9.321 -8.979 -8.742 -8.247 -7.291 -6.738 -7.439 -8.733 -8.596 ]
Y-axis values are as given b = [134 135 136 137 138 139 140 141 142 143 ]
I want to consider each set of values and find the difference between the number and its previous number for example a2-a1,a3-a2,a4-a3.... till a1000-a999. Depending upon these values if its increasing(difference is positive) or decreasing(difference is negative) or constant(difference is zero) I have to find out the threshold value of the given set. Please help me with the code.

採用された回答

Cris LaPierre
Cris LaPierre 2022 年 8 月 22 日
Do you mean a2-a1,a3-a2,a4-a3,...., a1000-a999?
If so, use the diff function.
a = [ -9.658 -9.321 -8.979 -8.742 -8.247 -7.291 -6.738 -7.439 -8.733 -8.596 ];
c=diff(a)
c = 1×9
0.3370 0.3420 0.2370 0.4950 0.9560 0.5530 -0.7010 -1.2940 0.1370
  3 件のコメント

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

その他の回答 (1 件)

the cyclist
the cyclist 2022 年 8 月 22 日
a = [2 3 5 7 11];
a - a' % All possible differences between pairs of elements of a
ans = 5×5
0 1 3 5 9 -1 0 2 4 8 -3 -2 0 2 6 -5 -4 -2 0 4 -9 -8 -6 -4 0
  7 件のコメント
Surabhi A S
Surabhi A S 2022 年 8 月 23 日
Oh sorry. I'm sorry for that, I typed it by mistake.
Thank you for the help

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

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by