Satellite color not changing dynamically

7 visualizaciones (últimos 30 días)
Krish
Krish el 28 de Feb. de 2024
Editada: Krish el 1 de Mzo. de 2024
I want that the satellite color changes to that of its current network manager.
When i move frame by frame by using advance function the color changes occur in the simulation but when I use the loop:
while sc.SimulationTime ~= sc.StopTime
sc.advance();
for leo_in=1:size(leo_satellites)
for nm_in=1:size(network_managers)
if detect_change_nm(leo_in,nm_in) ~= size(access_list{leo_in,nm_in}.accessIntervals,1)
detect_change_nm(leo_in,nm_in) = detect_change_nm(leo_in,nm_in) + 1;
% change color of satellite same as its network manager
leo_satellites(leo_in).matlab_sat.MarkerColor = network_managers(nm_in).gs.MarkerColor;
end
end
end
end
The simulation shows the initial color only.
Color change occuring when moving frame by frame
:
Originally they were red and not changed to green even though they must change color according to the code (using above loop)

Respuestas (1)

Gayatri
Gayatri el 29 de Feb. de 2024
Hi Krish,
In MATLAB, when you run a loop that updates graphical objects, you often need to manually force the graphics to render the updates. This is typically done using 'drawnow', which is a MATLAB function that forces the figure window to update and display any pending graphics events.
Here's an example of how 'drawnow' can be used:
x = 1:100;
y = sin(x);
figure
plot(x, y)
for i = 1:100
y = sin(x + i/10);
plot(x, y)
drawnow % Usage of drawnow
end
Please refer the below documentation for 'drawnow' function: https://in.mathworks.com/help/matlab/ref/drawnow.html
I hope it helps!
  3 comentarios
Gayatri
Gayatri el 1 de Mzo. de 2024
Can you please send the complete code files?
Krish
Krish el 1 de Mzo. de 2024
Editada: Krish el 1 de Mzo. de 2024
The main file that has to be executed is "Simulation_original.m"

Iniciar sesión para comentar.

Categorías

Más información sobre Reference Applications en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by