1

有谁知道如何从原始图中获得具有对应 x,y 点的矩阵的平均曲线?我的意思是,我假装中等单曲线。

由于我是 matlab 新手,因此任何代码或只是想法都会对我非常有帮助。非常感谢!

4

1 回答 1

1

好吧,您可以做的一件事是拟合参数曲线。这是一个关于如何对带有噪声的 8 字形执行此操作的示例:

function findParamFit
    clc, clf, hold on

    %# some sample data
    noise = @(t) 0.25*rand(size(t))-0.125;
    x     = @(t) cos(t)    + noise(t);
    y     = @(t) sin(2*t)  + noise(t);

    t = linspace(-100*rand, +100*rand, 1e4);

    %# initial data
    plot(x(t), y(t), 'b.')        

    %# find fits 
    options = optimset(...
        'tolfun', 1e-12,...
        'tolx', 1e-12);

    a = lsqcurvefit(@myFun_x, [1 1], t, x(t), -10,10, options);     
    b = lsqcurvefit(@myFun_y, [1 2], t, y(t), -10,10, options);

    %# fitted curve
    xx = myFun_x(a,t);
    yy = myFun_y(b,t);   
    plot(xx, yy, 'r.') 

end

function F = myFun_x(a, tt)
    F  = a(1)*cos(a(2)*tt);
end

function F = myFun_y(b, tt)
    F  = b(1)*sin(b(2)*tt);
end

请注意,这是拟合参数曲线的一种特别糟糕的方法,这从解决方案对初始值质量的极端敏感性可以看出lsqcurvefit。然而,拟合参数曲线将是可行的方法。

有你的谷歌查询:)

于 2012-09-18T15:10:54.993 回答