Fix Axis Values during for loop mobile plot in order to keep them from being executed each iteration.

2 次查看(过去 30 天)
I have the following code which generates a mobile plot for the Earth and Mercury during a year:
for k=1:length(t)
%clear figure
clf
%get data
t_k=t(k);
x_tm=xt(k);
y_tm=yt(k);
x_mm=xm(k);
y_mm=ym(k);
%Plot movement
p=plot(x_tm,y_tm,'co',x_mm,y_mm,'ko',x_mm*0,y_mm*0,'yo','Linewidth',8);
hold on
%plot outline of movement
plot(xt,yt,'b',xm,ym,'r','Linewidth',1);
hold on
%plot lines between objects
lx=[0 0 x_tm; x_tm x_mm x_mm];
ly=[0 0 y_tm; y_tm y_mm y_mm];
l=plot(lx,ly,'m','Linewidth',1);
%Details
grid on
xlabel('Distancia en Millones de Kms')
ylabel('Distancia en Millones de Kms')
title(['Posición de los planetas al día ',num2str(t_k)]);
drawnow limitrate
end
When running Run and Time Matlab shows me that the x & y label axis take considerable (about 4 & 3 seconds) to run, given that they are executed 366
times, one for each day.
How do i fix this? I intend to optimize this time, any suggestions would be gladly taken :)

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by