Any matlab codes for UAV trajectory generation for randomly distributed moving ground users, using any reference datasets

4 Ansichten (letzte 30 Tage)
Hello Mathwork Community,
I need a help to draw the trajectory of UAV based on the ground users mobility in cognitive Radio network in matlab. I need any reference/source codes that can be used to draw the trajectory of UAV based on the ground users mobility. I will be thankful if someone shares the informations or data in this regards.
Kind Regards!

Antworten (4)

Walter Roberson
Walter Roberson am 3 Jun. 2022
I suggest that you use animatedline() to draw the trajectory.
If you create a scatter() of the user locations and you record the handle returned by scatter(), then you can update the XData and YData properties of the handle in order to move the users efficiently.
Your question does not include any information about how to decide where to move the UAV

Khalid Khan
Khalid Khan am 3 Jun. 2022
@Walter Roberson, Thank you for your prompt response,
actually I am trying to draw the trajectory but not able to do so the code is below
clc
clearvars
% Set the random number generator seed, for reproducibility
rng default
% Number of iterations to run the algorithm
NITER = 10;
% Number of seconds to pause after each figure
NPAUSE = 1;
% Fixed circle parameters
NCIRCLES = 7;
% x0 = [100 450 500 650 900 900 800]';
% y0 = [700 200 600 500 400 100 850]';
% Number of users
NUSERS = 50; % <--- Change this to 200
for ni = 1:NITER
k = 0;
userCircle = randi(NCIRCLES,NUSERS,1);
usersPerCircle = histcounts(userCircle,1:NCIRCLES+1)';
% circleRadius = sqrt(usersPerCircle);
circleRadius = 10*sqrt(usersPerCircle);
circleRadius_max = 10*ceil(max(circleRadius*0.1)); % rounded to upper ten's
min_gap = 3*circleRadius_max; % min gap between groups - adapt factor here (min = 2)
figure(ni)
axis square
set(gca,"Box","on")
grid on;
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
axis([0 1000 0 1000])
fontSize = 10;
xlabel('Position X (1000m)', 'FontSize', fontSize);
ylabel('Position Y (1000m)', 'FontSize', fontSize);
title('Random Users Within Circles', 'FontSize', fontSize);
axis([0 1000 0 1000])
hold on
% create random values for circles position
a = randi([circleRadius_max,1000-circleRadius_max],NCIRCLES,2);
x0 = a(:,1);
y0 = a(:,2);
d0 = sqrt((x0-x0').^2 + (y0-y0').^2);
min_d0 = min(d0(d0>0));
while min_d0 <= min_gap % retry with new data if condition of gap distance is not met
a = randi([circleRadius_max,1000-circleRadius_max],NCIRCLES,2);
x0 = a(:,1);
y0 = a(:,2);
d0 = sqrt((x0-x0').^2 + (y0-y0').^2);
min_d0 = min(d0(d0>0));
k = k+1;
end
k % shows iterations amount to get a new valid set of coordinates that fullfil the required gap distance
for nc = 1:NCIRCLES
tnc = 2*pi*rand(usersPerCircle(nc),1);
% rnc = 10*circleRadius(nc)*rand(usersPerCircle(nc),1);
rnc = circleRadius(nc)*rand(usersPerCircle(nc),1);
x = x0(nc) + rnc.*cos(tnc);
y = y0(nc) + rnc.*sin(tnc);
h = plot(x,y,".");
set(h,'MarkerSize',8)
end
pause(NPAUSE)
hold off
end

Khalid Khan
Khalid Khan am 3 Jun. 2022
@Walter Roberson, would like to help me in this regards
I mean I am new to matlab, I need to generate the UAV and then follow these users mobility to plot the trajectory of UAV based on the mobility of these users.
I will be very grateful for this as I am trying but not able to draw the trajectory of UAV.
Kind Regards

Walter Roberson
Walter Roberson am 3 Jun. 2022
ux = randi(100);
uy = randi(100);
L = animatedline(ux, uy);
xlim([0 100])
ylim([0 100])
for K = 1 : 100
ux = ux + randi([-15 15]);
uy = uy + randi([-15 15]);
addpoints(L, ux, uy);
drawnow;
end
... using animatedline just like I said originally
  1 Kommentar
Walter Roberson
Walter Roberson am 3 Jun. 2022
See also https://www.mathworks.com/matlabcentral/answers/1732510-during-the-moving-random-points-i-don-t-see-animation-instead-i-see-re-scattering#comment_2196170

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu UAV finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by