gpt4 book ai didi

matlab - 在 Matlab 中最小化简单目标的最佳方法

转载 作者:行者123 更新时间:2023-12-03 16:58:46 26 4
gpt4 key购买 nike

找到此图像中蓝线沿 x 轴偏移的最佳方法是什么 unshifted 使其与红线相匹配?结果必须看起来像这张图片 shifted).在 MATLAB 中有像 fminunc 这样的复杂函数,但我必须处理一些时间限制,所以我想知道是否有更有效的方法。

编辑:数据来自模拟环境中激光扫描的距离测量。在 x 轴上,您可以看到每次扫描的方位(以弧度为单位)与 y 轴上以米为单位的测量范围。对于红点(引用扫描),轴承确实均匀分布。引用扫描始终如此,但当前扫描(蓝点)并非如此。

编辑:红点的数据

-1.5708    6.8542
-1.3963 6.9530
-1.2217 7.2137
-1.0472 7.6592
-0.8727 8.3326
-0.6981 9.2984
-0.5236 10.6477
-0.3491 12.5060
-0.1745 15.0092
0 18.2745
0.1745 22.3368
0.3491 27.1113
0.5236 32.4112
0.6981 38.0010

对于蓝点

-1.3963    7.0092
-1.2217 7.3112
-1.0472 7.8065
-0.8727 8.5420
-0.6981 9.5872
-0.5236 11.0407
-0.3491 13.0360
-0.1745 15.7225
0 19.1849
0.1745 23.4301
0.3491 28.3466
0.5236 32.4114

最佳答案

好吧,这不是“最佳”方式,但如果您不知道描述曲线的正确模型,这是一种方式:

% your first plot
figure(1), clf, hold on
plot(red(:,1), red(:,2), 'ro-')
plot(blue(:,1), blue(:,2), 'bo-')

% approximate reference with splines, so it can be evaluated anywhere
ppred = spline(red(:,1),red(:,2));

% minimize the distance between the curves
f = @(x) norm( ppval(ppred, blue(:,1)+x)-blue(:,2) );
x0 = fminsearch(f, 0);
blue(:,1) = blue(:,1)+x0;

% pretty close to your second plot
plot(blue(:,1), blue(:,2), 'ko-')

关于matlab - 在 Matlab 中最小化简单目标的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12857108/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com