如何在 MatLab 中从 xyz 坐标制作 3D 线对象,以便它可用于 Procrustes 分析?

How do I make a 3D line object in MatLab from xyz coordinates such that it is usable in a Procrustes Analysis?

我有一组由坐标 x、y 和 z 组成的数据,我绘制这些数据以创建 3D 线。我想执行 Procrustes 分析来查找此 3D 线的形状与另一个默认形状之间的相似性。当我尝试使用任何形状分析函数或 Procrustes 函数时,它会在我创建的用于保存它的 3D 绘图输入上给我一个无效句柄错误,即 'myLine'。如何将此 3D 坐标图转换为可用于 Procrustes 或其他功能的对象?

3D line created from the coordinates in code below.

myLine = plot3(GPS(:,8),GPS(:,9),GPS(:,10))

下面是我尝试使用的形状分析函数

function [f,g]=ShapeAnalysis(f,g)
% SHAPEANALYSIS(F,G) Plots the parameterised curves before and after
% each stage of translating, scaling and aligning. Outputs are
% parameterised curves ready for Procustes shape analysis.

LW = 'LineWidth'; FS = 'FontSize';
% Plot orignal
subplot(2,2,1)
plot(f,'r',LW,2), hold on, axis equal, plot(g,'k',LW,2)
title('Orignal',FS,16)

% Translate mean to 0.
f = f-mean(f); g = g-mean(g);
subplot(2,2,2)
plot(f,'r',LW,2), hold on, axis equal, plot(g,'k',LW,2)
title('After translation',FS,16)

% Scale so RMSD is 1.
f = f/norm(f); g = g/norm(g);
subplot(2,2,3)
plot(f,'r',LW,2), hold on, axis equal, plot(g,'k',LW,2)
title('After scaling',FS,16)

% Align major axis.
subplot(2,2,4)
% Find argument of major axis.
[~,fxmax]=max(abs(f)); [~,gxmax]=max(abs(g));
rotf=angle(f(fxmax)); rotg=angle(g(gxmax));
% Rotate both so major axis lies on the +ve real axis.
x = chebfun('x',[0,2*pi]);
f = exp(-1i*rotf)*f(mod(x+fxmax,2*pi));
g = exp(-1i*rotg)*g(mod(x+gxmax,2*pi));
plot(f,'r',LW,2), hold on, axis equal, plot(g,'k',LW,2)
title('After aligning',FS,16), hold off

end

编辑:我想更简单的表达方式是如何引用用一个变量创建的线,这样如果我写 'plot(myLine)',其中 myLine = plot3(GPS(: ,8),...), 它将创建相同的行。这样我就可以将一个变量传递给比较函数。 (需要说明的是,我在绘制直线时没有问题,只是通过参考坐标而不是直线方程来操纵它)

编辑:我试图将 myLine 传递到形状分析中,并说出一个圆的方程来比较 myLine 与第二个条目的接近程度。所以我输入:

>>myLine = plot3(GPS(:,8),GPS(:,9),GPS(:,10))
>>ShapeAnalysis(myLine,circle(0,0,1))

输入后出现如下错误:

Error using plot
Invalid handle.

Error in ShapeAnalysis (line 9)
    plot(f,'r',LW,2), hold on, axis equal, plot(g,'k',LW,2)

我希望这能稍微澄清我的问题。

您几乎回答了您自己的问题:"How can I convert this 3D plot of coordinates to a usable object...?"像任何对象一样,您需要引用它才能进行操作:

myLine = plot3(GPS(:,8),GPS(:,9),GPS(:,10))

现在你可以绕过 myLine 看看你能用它做什么。