How can I get rid of the lines between the drawn points in "animatedline"?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
kahlan hasan
am 4 Jun. 2022
Kommentiert: kahlan hasan
am 5 Jun. 2022
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
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 4 Jun. 2022
animatedline('linestyle', 'none', 'marker', '+')
3 Kommentare
Walter Roberson
am 4 Jun. 2022
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Animation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!