Hi all,
during simulation, I like to use the waiting time for looking at plots from earlier runs, editing them, etc. Unfortunately, the running simulation plots into the current figure, such that the next update is included there. It is relatively easy to change this, such that the simulation update sticks to its own figure, regardless of other interactive work. Just replace this block (line 918):
% update plot
imagesc(kgrid.y_vec(y1:y2) * scale, kgrid.x_vec(x1:x2) * scale, p_plot, plot_scale);
colormap(COLOR_MAP);
ylabel(['x-position [' prefix 'm]']);
xlabel(['y-position [' prefix 'm]']);
axis image;
With this block:
if t_index == 1
% create plot
imagehandle = imagesc(kgrid.y_vec(y1:y2) * scale, kgrid.x_vec(x1:x2) * scale, p_plot, plot_scale);
colormap(COLOR_MAP);
ylabel(['x-position [' prefix 'm]']);
xlabel(['y-position [' prefix 'm]']);
axis image;
else
% update plot
set(imagehandle, 'CData', p_plot)
end
It does exactly the same during the first plot (plot creation), but for subsequent plots, the handle to the data is used to replace the data only. This means that the plot itself with its object structure is preserved, also making the run faster by 1% for my typical use-cases. I donate this code to the project.
Regards,
Heinrich