当我通过你的函数得到了一个人的移动轨迹trajectory,请再写一个matlab函数,输入是轨迹trajectory,和采样时间T,移动速度v;输出是采样坐标向量
时间: 2024-05-21 07:12:02 浏览: 109
trajetory.rar_matlab 轨迹跟踪_trajectory_轨迹 matlab_轨迹跟踪_轨迹跟踪MATLAB
function [coordinates] = sampled_coordinates(trajectory, T, v)
% Sample the coordinates based on trajectory, sampling time T, and velocity v
num_points = length(trajectory);
coordinates = zeros(2, num_points);
for i = 1:num_points
if i == 1
coordinates(:,i) = trajectory(:,i); % Starting position
else
distance = norm(trajectory(:,i) - trajectory(:,i-1));
time_diff = distance / v;
num_samples = ceil(time_diff / T);
for j = 1:num_samples
if j == num_samples
time_fraction = 1; % Last sample
else
time_fraction = j * T / time_diff;
end
coordinates(:,i) = trajectory(:,i-1) + (trajectory(:,i) - trajectory(:,i-1)) * time_fraction;
end
end
end
end
阅读全文