How to create gradient of randomly spaced data at each point of input array
17 ビュー (過去 30 日間)
古いコメントを表示
Christopher Saltonstall
2018 年 5 月 10 日
回答済み: Star Strider
2018 年 5 月 10 日
I have a set of data, y, with non-uniformly spaced independent variable, x. I want to calculate the gradient of this data at each point in y so that dy/dx is the same length as y. If i use gradient, the data points in x must be equally spaced. If I use diff(y)./diff(x) the length of the resulting array is different than y. Suggestions?
0 件のコメント
採用された回答
Star Strider
2018 年 5 月 10 日
For unequally-spaced points, I always use:
dydx = gradient(y)./gradient(x);
It depends on the result you want.
0 件のコメント
その他の回答 (1 件)
Ameer Hamza
2018 年 5 月 10 日
If you have a model of the data (i.e. the relation between x and y is polynomial or exponential etc.), then you can use curve fitting to fit a curve to the data using fit() function. After a curve fit is obtained, you can find derivative at the specified points using differentiate().
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Linear and Nonlinear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!