计算一系列绘图值中增长最快/下降最快的部分

发布于 2024-12-18 18:27:02 字数 209 浏览 2 评论 0原文

我有一系列绘制的值 (x, y)。我正在寻找一种方法来识别增长/下降速度最快的段 {(Xi, Yi), (Xi+1, Yi+1)} 。 绘制值 在示例图像中,这些段被标记并具有以下 X 坐标 (516, 550) 表示最快增加的段,(620, 635) 表示最快减少的段。我如何定义一个算法来做到这一点?

I have a series of plotted values (x, y). I'm searching for a way to identify the segments {(Xi, Yi), (Xi+1, Yi+1)} with the fastest growing/decresing rate.
Plotted values
In example image, these segments are tagged and have the following X coords (516, 550) for the fastest increasing segment and (620, 635) for the fastest decreasing segment. How can I define an algorithm to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽梦忆笙歌 2024-12-25 18:27:02

计算每条线段的斜率。跟踪坡度的最大值和最小值。这些将分别对应于增长率最大和下降率最大的部分。

Calculate the slope of each line segment. Keep track of the maximum and minimum values of the slope. These will correspond to the segments with the greatest rate of increase and the greatest rate of decrease, respectively.

忘羡 2024-12-25 18:27:02

以下示例代码应该为您提供解决问题的方法:

%Create x and y values
x = 1:0.5:20;
y = real((x-15).^2.2.*sin(x)-0.5*x);

%Plot
f1 = figure(1);clf
plot(x,y)

%Calculate derivative
dx = abs(conv(y,[1 -1],'same'));

%Find maximum change
[maxSlope idx] = find(dx==max(dx));

%Display derivative and maximum change points
hold on
plot(x+0.5,dx,'g')
plot(x(idx+1),y(idx+1),'*r')
grid on

legend('Data series','abs(Derivative)','Point of maximum change');

我创建了一个玩具数据集,并找到了 y 变化最大的点。请注意,此处假设等距点(x 线性增加)。你的数据分布均匀吗?

结果图:
在此处输入图像描述

The following example code should provide you with a way forward in solving your problem:

%Create x and y values
x = 1:0.5:20;
y = real((x-15).^2.2.*sin(x)-0.5*x);

%Plot
f1 = figure(1);clf
plot(x,y)

%Calculate derivative
dx = abs(conv(y,[1 -1],'same'));

%Find maximum change
[maxSlope idx] = find(dx==max(dx));

%Display derivative and maximum change points
hold on
plot(x+0.5,dx,'g')
plot(x(idx+1),y(idx+1),'*r')
grid on

legend('Data series','abs(Derivative)','Point of maximum change');

I have created a toy data set, and found the point where y changes the most. Note that equally spaced points (x increases linearly) is assumed here. Is your data evenly spaced?

Resulting plot:
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文