How can I get rid of the lines between the drawn points in "animatedline"?

3 次查看(过去 30 天)
I would like to get rid of the lines that are drawn between the current positions and the next positions of the moving points as well as the drawn lines between the points them selves!
clear all
close all
% parameters
x_axis_limit = [0 1e3]; % simulation area in meters
Number_of_positions =5;
linspce_lngth = 100; % the number of points to be drown along the line.
Number_of_users = 5;
x = zeros(Number_of_users,linspce_lngth); % a vector to hold the linear space vector of x
y = zeros(Number_of_users,linspce_lngth); % a vector to hold the linear space vector of y
initial_x_position = randi(x_axis_limit,Number_of_users,1); % generate the initial position of x for all users
initial_y_position = randi(x_axis_limit,Number_of_users,1); % generate the initial position of y for all users
next_x_position = randi(x_axis_limit,Number_of_users,1); % generate the next position of x for all users
next_y_position = randi(x_axis_limit,Number_of_users,1); % generate the next position of y for all users
for k = 1:Number_of_users
x(k,:) = linspace(initial_x_position(k),next_x_position(k),linspce_lngth); % generate the linear space vector of x
y(k,:) = linspace(initial_y_position(k),next_y_position(k),linspce_lngth); % generate the linear space vector of y
end
axis([0,1000,0,1000]);
h = animatedline;
for i = 1:Number_of_positions
for j = 1:length(x)
for m = 1:Number_of_users
clearpoints(h)
addpoints(h,x(m,j),y(m,j));
drawnow
end
end
current_x_position = next_x_position; % update the current position of x
current_y_position = next_y_position; % update the current position of y
next_x_position = randi(x_axis_limit, Number_of_users, 1); % generate the next position of x
next_y_position = randi(x_axis_limit, Number_of_users, 1); % generate the next posiotion of y
for k = 1:Number_of_users
x(k,:) = linspace(current_x_position(k),next_x_position(k),linspce_lngth); % generate the linear space vector of x for all users
y(k,:) = linspace(current_y_position(k),next_y_position(k),linspce_lngth); % generate the linear space vector of y for all users
end
end

采纳的回答

Walter Roberson
Walter Roberson 2022-6-4
animatedline('linestyle', 'none', 'marker', '+')
  3 个评论
Walter Roberson
Walter Roberson 2022-6-4
Instead of using clearpoints each time, configure maximum number of points to 1
But I would have thought you would want one point for each user, rather than one total point.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Animation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by