function makeMovie(run_index) set(0,'defaulttextInterpreter','latex') set(groot, 'defaultAxesTickLabelInterpreter','latex'); set(groot, 'defaultLegendInterpreter','latex'); folder_path = './Data'; FileDir = dir(sprintf(horzcat(folder_path, '/Run_%03i/*.mat'),run_index)); NumFiles = numel(FileDir); Data = load(sprintf(horzcat(folder_path, '/Run_%03i/psi_%i.mat'),run_index,1),'Params','Transf'); Params = Data.Params; Transf = Data.Transf; x = Transf.x; y = Transf.y; z = Transf.z; dx = x(2)-x(1); dy = y(2)-y(1); dz = z(2)-z(1); mkdir(sprintf(horzcat(folder_path, '/Run_%03i/Figures'),run_index)) outputVideo = VideoWriter(fullfile(horzcat(folder_path, '/Movie.avi'))); outputVideo.FrameRate = 10; open(outputVideo) figure(1); x0 = 800; y0 = 200; width = 800; height = 600; set(gcf,'position',[x0,y0,width,height]) for ii = 1:(NumFiles-1) Data = load(sprintf(horzcat(folder_path, '/Run_%03i/psi_%i.mat'),run_index,ii),'psi','muchem','T','Observ'); psi = Data.psi; muchem = Data.muchem; T = Data.T; Observ = Data.Observ; %Plotting subplot(2,3,1) n = abs(psi).^2; nxz = squeeze(trapz(n*dy,2)); nyz = squeeze(trapz(n*dx,1)); nxy = squeeze(trapz(n*dz,3)); plotxz = pcolor(x,z,nxz'); shading interp set(plotxz, 'EdgeColor', 'none'); xlabel('$x$ [$\mu$m]'); ylabel('$z$ [$\mu$m]'); subplot(2,3,2) plotyz = pcolor(y,z,nyz'); shading interp set(plotyz, 'EdgeColor', 'none'); xlabel('$y$ [$\mu$m]'); ylabel('$z$ [$\mu$m]'); subplot(2,3,3) plotxy = pcolor(x,y,nxy'); shading interp set(plotxy, 'EdgeColor', 'none'); xlabel('$x$ [$\mu$m]'); ylabel('$y$ [$\mu$m]'); subplot(2,3,4) plot(Observ.tVecPlot*1000/Params.w0,Observ.NormVec,'-b') ylabel('Normalization'); xlabel('$t$ [$m$s]'); subplot(2,3,5) plot(Observ.tVecPlot*1000/Params.w0,1-2*Observ.PCVec/pi,'-b') ylabel('Coherence'); xlabel('$t$ [$m$s]'); ylim([0,1]) subplot(2,3,6) plot(Observ.tVecPlot*1000/Params.w0,Observ.EVec,'-b') ylabel('E'); xlabel('$t$ [$m$s]'); tVal = Observ.tVecPlot(end)*1000/Params.w0; sgtitle(sprintf('$\\mu =%.3f \\hbar\\omega_0$, $T=%.1f$nK, $t=%.1f$ms',muchem,T,tVal)) drawnow saveas(gcf,sprintf(horzcat(folder_path, '/Run_%03i/Figures/Image_%i.jpg'),run_index,ii)) img = imread(sprintf(horzcat(folder_path, '/Run_%03i/Figures/Image_%i.jpg'),run_index,ii)); writeVideo(outputVideo,img) clf end close(outputVideo) close(figure(1)) delete(sprintf(horzcat(folder_path, '/Run_%03i/Figures/*.jpg'),run_index)) % deleting images after movie is made end