Matlab确定曲线 [英] matlab determine curve

查看:114
本文介绍了Matlab确定曲线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Does anyone know how to obtain a mean curve having a matrix with the correspondent x,y points from the original plot? I mean, I pretend a medium single curve.

由于我是matlab的新手,所以任何代码或只是想法对我都会非常有帮助. 非常感谢你!

Any code or just ideas would be very very helpful for me since I am new with matlab. Thank you very much!

推荐答案

好吧,您可以做的一件事就是拟合参数曲线.下面是一个示例,该示例如何针对图8上有噪声的情况执行此操作:

Well, one thing you can do is fit a parametric curve. Here's an example on how to do this for a figure-8 with noise on it:

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的初始值的质量非常敏感.尽管如此,拟合参数曲线仍是可行的方法.

Note that this is a particularly bad way to fit parametric curves, as is apparent here by the extreme sensitivity of the solution to the quality of the initial values to lsqcurvefit. Nevertheless, fitting a parametric curve will be the way to go.

有您的Google查询:)

There's your google query :)

这篇关于Matlab确定曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆