I am trying to create a movie of an EM wave propagating through time using plot3, and I would like to fix the axes of my plot so that the size doesn't continually update. My code right now is a little rough, but hopefully you can see my issue. Outside loop is the 'time' loop, and I only have data up to that index. Additionally, if you have any suggestions for plotting perpendicular components of a wave, I would be all ears. Ideally, it would look something like this.
plot_step = 5;num_frames = max_time/plot_step;% movie_vector = struct('cdata','colormap');
ax = axes; ax.ALimMode = 'manual';ax.XLim = [0 200]; ax.YLim = [0 1]; ax.ZLim = [-0.001 0];ax.ZDir = 'reverse';for i = 1:max_time for k = 1:max_distance-2 hz(k) = hz(k) + (ey(k+1) - ey(k))/eta; end for j = 2:max_distance-1 ey(j) = ey(j) + (hz(j) - hz(j-1))*eta; end ey(1) = exp(-(i-31)^2/100); %This is where I am having trouble
if mod(i,plot_step) == 0%I am passing my previously defined axis handle to plot3, but still end up with bounds decided MATlab.
plot3(ax,x(1:i),ey(1:i),zeros(1,i)); hold on plot3(ax,x(1:i),zeros(1,i),hz(1:i)); hold off %Hold off so that new data doesn't overlap old.
movie_vector(i/plot_step) = getframe; end end
Best Answer