How to find two local slopes in an arbitrary curve?

7 ビュー (過去 30 日間)
Body_sea
Body_sea 2013 年 6 月 3 日
回答済み: Jules Ray 2015 年 6 月 16 日
I am used Matlab to find a model from curves. So i am processing curvesand i have some difficult to find two local slopes?
For information i am not an expert in math.
Thanks for help!
Best regards
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 3 日
This is not clear
Jan
Jan 2013 年 6 月 3 日
What does "processing curves" exactly mean? Do youz have two vector of x- and y_values? Or a sheet of paper with a hand-drawn line?

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

回答 (5 件)

Iain
Iain 2013 年 6 月 3 日
The general expression to calculate "slope" is (y2 - y1) / (x2 - x1)
If you have a vector of "y" values and "x" values of the same length, you can:
slope = diff(y) ./ diff(x);
slope_x_vals = (x(2:end) + x(1:end-1))/2;
plot(slope_x_vals,slope_y_vals)
If your y value is in metres, and your x value is in seconds, the units of "slope" is metres per second.

Body_sea
Body_sea 2013 年 6 月 3 日
Hello,
I see my question is not clear...
I have a curve stored in a vector X and Y as the following picture :
in an arbitraru curve i know there a two local slopes. So my question is how to find the two local slopes in the curve?
With the picture i hope it is clear.
Best regards.

Jan
Jan 2013 年 6 月 3 日
The gradient function calculates the slope in a fast and stable way.

Body_sea
Body_sea 2013 年 6 月 3 日
I know the gradient function in Matlab. But you can see, my problem is not here, i am looking for the two local slope. i mean after to have the gradient of the curve, i want to find the local linear slope and to make sure this is the good of the two slopes i want.
An idea?
Regards

Jules Ray
Jules Ray 2015 年 6 月 16 日
Use ginput (four in this case) to the boundaries or the limits that enclose both areas, for each area use for polyfit, and lineal interpolations, this allows estimates the slope but also the associated 2 sigma error of your measurements

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by