How do I find slope for large dataset?

4 ビュー (過去 30 日間)
Stephen Tete
Stephen Tete 2022 年 11 月 3 日
コメント済み: Stephen Tete 2022 年 11 月 15 日
I have a large dataset and i want to compute the gradient for between two corresponding data and their corresponding times for a large data.
time data
20 6.6
30.3 7.2
41 -8.6
. .
. .
for a large dataset i want to do
A = (7.2 - 6.6) / (30.3 - 20) and store all output in a column format in A.
I tried to use a for loop but my output is not what it needs to be

採用された回答

Davide Masiello
Davide Masiello 2022 年 11 月 3 日
Just do
A = diff(data)./diff(time);
  1 件のコメント
Stephen Tete
Stephen Tete 2022 年 11 月 3 日
Thank you

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

その他の回答 (1 件)

Jan
Jan 2022 年 11 月 14 日
The command gradient(x, t) solves this similar to diff(x) ./ diff(t), but with using the 2-sided difference except for the margins. This replies the same number of elements as the input and is numerically more stable.
  1 件のコメント
Stephen Tete
Stephen Tete 2022 年 11 月 15 日
Oh okay thank you

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

カテゴリ

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

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by