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

2 ビュー (過去 30 日間)
kahlan hasan
kahlan hasan 2022 年 6 月 4 日
コメント済み: kahlan hasan 2022 年 6 月 5 日
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.
kahlan hasan
kahlan hasan 2022 年 6 月 5 日
Yes, exactly, one moving point of each user is what I am trying to have.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by