1

我有一些数据是从一个人那里获得的,该人将光标从屏幕上显示的一个目标移动到距离原始起始位置 10 厘米的另一个直线目标。我有这个人的 15 个动作。我拥有的数据是每次移动时光标的瞬时 x 位置x(t)和 y 位置。y(t)因为个人没有以完全相同的速度从一个动作移动到另一个动作,所以每个动作的样本数量是不一样的。下面,我展示了所有运动的 x 位置、y 位置和完整的 xy 轨迹。下载数据的链接也在这里。希望这能对数据的性质有所了解。请注意,光标位置始终从[0,0]点,但不要总是在[0,10]点结束。

图。1

图2

我的任务是将光标的 x 位置线性插值到每 0.05cm 的 y 位置向量上,以便在移动中对齐光标测量值(也就是说,我必须获得x(y)。我想在下面展示我的代码并得到关于我是否正确执行此操作的一些反馈:

%% Try interpolating x as a function of y (i.e., transform x(t) to x(y))
%Goal is to linearly interpolated the x-positions of the cursor onto a
%vector of y-positions every 0.05cm to align the hand path measurements
%across movements

clear all;
close all;
home;

%load the data: xpos & ypos
load('pos_data.mat')

%create cell array that will hold interpolated data
x_interp = cell(size(xpos));
y_interp = cell(size(ypos));

%construct grid vector
ypos_grid = [0:0.05:10];
num_interp_samples = length(ypos_grid);

%loop through each movement
for k=1:num_movements
    %get data for the current movement
    xp = xpos{k};
    yp = ypos{k};
    
    %to deal with duplicate samples, I add a very small offset to each
    %sample to make them all unique
    offset = cumsum([0:length(yp)-1]*1e-16);
    yp2 = yp+offset(:);
    
    %interpolate xp wrt yp
    x_interp{k} = interp1(yp2, xp, ypos_grid);
    
    %interpolate yp so that it is the same size as x_interp
    t = linspace(1,length(yp2),length(yp2));
    ti = linspace(1,length(yp2),num_interp_samples);
    y_interp{k} = interp1(t, yp2, ti);
    
end

认为这应该是比较简单的,但是当我绘制插值数据时,它看起来有点奇怪。见下文:

图3

也就是说,轨迹似乎失去了很多“曲率”,这让我很担心。请注意,在绘制插值轨迹时,我只是在做:

figure; hold on;
for k=1:num_movements
    plot(x_interp{k}, y_interp{k}, 'color', 'k');
end
xlabel('x-position (cm)');
ylabel('y-position (cm)');
title('Examples of complete trajectories (interpolated data)');
axis equal;

以下是我的具体问题:

(1) 我是否正确插值?

(2) 如果 (1) 的答案是肯定的,那么我是否正确解释了插值结果?具体来说,为什么轨迹的形状看起来像它们一样(缺乏曲率)?

(3)我是否可能错过了获得后x(y),我应该将数据重新转换回的步骤x(t)

4

0 回答 0