How do I find slope for large dataset?
2 views (last 30 days)
Show older comments
Stephen Tete
on 3 Nov 2022
Commented: Stephen Tete
on 15 Nov 2022
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
0 Comments
Accepted Answer
More Answers (1)
Jan
on 14 Nov 2022
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.
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!