Matlab 如何找到每个曲率点的最小值?

Matlab 如何找到每个曲率点的最小值?,matlab,curve-fitting,curve,Matlab,Curve Fitting,Curve,我用多项式曲线拟合来分析我的数据(polyfit和polyval),我得到了这样的曲线。我想找到每条曲线的最小点(红点)。如果我使用min(),我将只得到一条曲线上的点。如何做到这两点 谢谢你这么简单: % Your polynomial coefficients c = [-1 4 5 2 6 2 4 5]; % Find real roots of its derivative R = roots( [numel(c)-1 : -1 : 1] .* c(1:end-1) ); R = R

我用多项式曲线拟合来分析我的数据(polyfit和polyval),我得到了这样的曲线。我想找到每条曲线的最小点(红点)。如果我使用min(),我将只得到一条曲线上的点。如何做到这两点

谢谢你这么简单:

% Your polynomial coefficients
c = [-1 4 5 2 6 2 4 5];

% Find real roots of its derivative
R = roots( [numel(c)-1 : -1 : 1] .* c(1:end-1) );
R = R(imag(R)==0);

% Compute and sort function values of these extrema
if ~isempty(R)

    [yExtrema, indsExtrema] = sort(polyval(c, R));
    xExtrema = R(indsExtrema);

    % Extract the two smallest ones
    yMins = yExtrema(1:2);
    xMins = xExtrema(1:2);

else
    yMins = [];
    xMins = [];

end
简单:

% Your polynomial coefficients
c = [-1 4 5 2 6 2 4 5];

% Find real roots of its derivative
R = roots( [numel(c)-1 : -1 : 1] .* c(1:end-1) );
R = R(imag(R)==0);

% Compute and sort function values of these extrema
if ~isempty(R)

    [yExtrema, indsExtrema] = sort(polyval(c, R));
    xExtrema = R(indsExtrema);

    % Extract the two smallest ones
    yMins = yExtrema(1:2);
    xMins = xExtrema(1:2);

else
    yMins = [];
    xMins = [];

end

你可以将你的信号与
减(-)
一起使用,或者看看我在哪里创建了一个非常基本的局部极小值脚本。这可能有点离题,抱歉,但你的拟合似乎完全不对。你确定你应该使用多项式来拟合吗?你不能用三次样条插值得到更好的结果吗?同意@thewaywewalk。。。。你为什么这么合适?不合身会比我在图片上看到的要好。无论如何,我相信有一个函数
findpeaks
可能会对您有所帮助。@Werner谢谢您的回答,我会试试。@BowHouse只需使用样条插值而不是多项式,它就能解决您的问题。然后你也可以用同样的方法应用FindPeak。你可以用你的信号减去(-),或者看看我在哪里创建了一个非常基本的局部极小值脚本。这可能有点离题,抱歉,但你的拟合似乎完全不对。你确定你应该使用多项式来拟合吗?你不能用三次样条插值得到更好的结果吗?同意@thewaywewalk。。。。你为什么这么合适?不合身会比我在图片上看到的要好。无论如何,我相信有一个函数
findpeaks
可能会对您有所帮助。@Werner谢谢您的回答,我会试试。@BowHouse只需使用样条插值而不是多项式,它就能解决您的问题。然后也可以用同样的方法应用FindPeak。