function adjust_image(tripodNumber, startTime, deltaT, theOrient, theHeight) % % adjust_image(tripodNumber, startTime, deltaT, theOrient, theHeight) % % Function which will load all of the images for tripodNumber (starting % at startTime with a time difference between images of deltaT) and will % create the animation. "theOrient" is the compass direction (in % degrees CW from N) of the tripod (this is the direction of the compass % in the images + 15 degrees, compensating for the difference between true % north and magnetic north), and "theHeight" is the height (in cm) % of the camera above the seafloor. %Soupy Alexander, 11/17/03 %This Matlab m-file was used to create portions of U.S. Geological Survey %Data Series 85. Although this program has been used by the USGS, no %warranty, expressed or implied, is made by the USGS or the United States %Government as to the accuracy and functioning of the program and related %program material nor shall the fact of distribution constitute any such %warranty, and no responsibility is assumed by the USGS in connection %therewith. %Citation: Butman, Bradford, Alexander, P. Soupy, Anderson, S.P., %Lightsom, F.L., Scotti, Alberto, and Beardsley, R.C., 2004, The %Massachusetts Bay Internal Wave Experiment, August 1998: Data Report: %U.S. Geological Survey Data Series 85, 1 DVD-ROM. theWidth= 2*theHeight*tan(27*pi/180); %Get the width of the images on the seafloor targetDirectory = ['C:\SCHTUFF\TRIPOD_MOVIE\TRIPOD' num2str(tripodNumber, '%03.0f') ... '\IMAGES']; greenColor = [0.2 0.6 0.2]; if tripodNumber == 535 dataDirectory = 'C:\SCHTUFF\DATAARCHIVE\DATAFILES\MBAY_IWAVE'; attnFile = fullfile(dataDirectory, '5351tcp-a.nc'); psdFile = fullfile(dataDirectory, '5351psd-a.nc'); currFile = fullfile(dataDirectory, '5344-a.cdf'); currFileH = fullfile(dataDirectory, '5344-a1h.cdf'); currEast = 'east'; currNorth = 'north'; tempFile = fullfile(dataDirectory, '5351tcp-a.nc'); theFactor = 1; maxGreen = 5; theStrip = 570; elseif tripodNumber == 501 dataDirectory = 'C:\SCHTUFF\MASS_BAY\MBLT_REPORT\DATAFILES'; currFile = fullfile(dataDirectory, '5011spd-a_d3.nc'); attnFile = fullfile(dataDirectory, '5011att-a_d1.nc'); psdFile = fullfile(dataDirectory, '5011p-a_d1.nc'); tempFile = fullfile(dataDirectory, '5011tct-a_d1.nc'); currEast = 'u_1205'; currNorth = 'v_1206'; theFactor = 1; maxGreen = 5; theStrip = 580; elseif tripodNumber == 507 dataDirectory = 'C:\SCHTUFF\MASS_BAY\MBLT_REPORT\DATAFILES'; currFile = fullfile(dataDirectory, '5071spd-a_d3.nc'); tempFile = fullfile(dataDirectory, '5071tct-a_d1.nc'); psdFile = fullfile(dataDirectory, '5071p-a_d1.nc'); attnFile = fullfile(dataDirectory, '5071tct-a_d1.nc'); currEast = 'u_1205'; currNorth = 'v_1206'; theFactor = 1; maxGreen = 5; theStrip = 580; elseif tripodNumber == 516; dataDirectory = 'C:\SCHTUFF\MASS_BAY\MBLT_REPORT\DATAFILES'; currFile = fullfile(dataDirectory, '5161v-a_d1.nc'); tempFile = fullfile(dataDirectory, '5161tcp-a.nc'); psdFile = fullfile(dataDirectory, '5161var-a_d1.nc'); attnFile = fullfile(dataDirectory, '5161tcp-a.nc'); currEast = 'u_1205'; currNorth = 'v_1206'; theFactor = 1; maxGreen = 5; theStrip = 580; elseif tripodNumber == 530 dataDirectory = 'C:\SCHTUFF\MASS_BAY\MBLT_REPORT\DATAFILES'; currFile = {fullfile(dataDirectory, '5301Av-a_d1.nc'); ... fullfile(dataDirectory, '5301Bv-a_d1.nc')}; tempFile = {fullfile(dataDirectory, '5301Atcp-a.nc')}; psdFile = {fullfile(dataDirectory, '5301Avar-a_d1.nc'); ... fullfile(dataDirectory, '5301Bvar-a_d1.nc')}; attnFile = {fullfile(dataDirectory, '5301Atcp-a.nc')}; currEast = 'u_1205'; currNorth = 'v_1206'; theFactor = 1; maxGreen = 3; theStrip = 580; elseif tripodNumber == 540 dataDirectory = 'C:\SCHTUFF\MASS_BAY\MBLT_REPORT\DATAFILES'; currFile = fullfile(dataDirectory, '5401v-a_d1.nc'); tempFile = fullfile(dataDirectory, '5401tcp-a.nc'); psdFile = fullfile(dataDirectory, '5401var-a_d1.nc'); attnFile = fullfile(dataDirectory, '5401tcp-a.nc'); currEast = 'u_1205'; currNorth = 'v_1206'; theFactor = 1; maxGreen = 5; theStrip = 570; elseif tripodNumber == 552 dataDirectory = 'C:\SCHTUFF\MASS_BAY\MBLT_REPORT\DATAFILES'; currFile = fullfile(dataDirectory, '5521v-a_d1.nc'); tempFile = fullfile(dataDirectory, '5521tcp-a.nc'); psdFile = fullfile(dataDirectory, '5521var-a_d1.nc'); attnFile = fullfile(dataDirectory, '5521tcp-a.nc'); currEast = 'u_1205'; currNorth = 'v_1206'; theFactor = 1; maxGreen = 5; theStrip = 580; elseif tripodNumber == 569 dataDirectory = 'C:\SCHTUFF\MASS_BAY\MBLT_REPORT\DATAFILES'; currFile = {fullfile(dataDirectory, '5692Av-a_d1.nc'); ... fullfile(dataDirectory, '5692Bv-a_d2.nc')}; tempFile = {fullfile(dataDirectory, '5692Atcp-a.nc'); ... fullfile(dataDirectory, '5692Btcp-a.nc')}; psdFile = {fullfile(dataDirectory, '5692Avar-a_d1.nc'); ... fullfile(dataDirectory, '5692Bpsd-a.nc')}; attnFile = {fullfile(dataDirectory, '5692Atcp-a.nc'); ... fullfile(dataDirectory, '5692Btcp-a.nc')}; currEast = 'u_1205'; currNorth = 'v_1206'; theFactor = 1; maxGreen = 5; theStrip = 570; elseif tripodNumber == 625 dataDirectory = 'C:\SCHTUFF\MASS_BAY\MBLT_REPORT\DATAFILES'; currFile = fullfile(dataDirectory, '6252v-a.nc'); tempFile = fullfile(dataDirectory, '6252tcp-a.nc'); psdFile = fullfile(dataDirectory, '6252psd-a.nc'); attnFile = fullfile(dataDirectory, '6252att-a.nc'); currEast = 'u_1205'; currNorth = 'v_1206'; theFactor = 1; maxGreen = 1; theStrip = 550; elseif tripodNumber == 690 dataDirectory = 'C:\SCHTUFF\MASS_BAY\MBLT_REPORT\DATAFILES'; currFile = fullfile(dataDirectory, '6902v-a_d1.nc'); tempFile = fullfile(dataDirectory, '6902tcp-a.nc'); psdFile = fullfile(dataDirectory, '6902psd-a.nc'); attnFile = fullfile(dataDirectory, '6902tcp-a.nc'); currEast = 'u_1205'; currNorth = 'v_1206'; theFactor = 1; maxGreen = 5; theStrip = 580; end saveDirectory = ['C:\SCHTUFF\TRIPOD_MOVIE\TRIPOD' num2str(tripodNumber, '%03.0f')]; frameDirectory = ['C:\SCHTUFF\TRIPOD_MOVIE\TRIPOD' num2str(tripodNumber, '%03.0f') '_FRAMES']; imageWidth = 600; imageHeight = 371; frameWidth = imageWidth + 100; frameHeight = 50 + imageHeight + 50 + imageWidth/4 + 50; dayLimits = [-2 2]; tic %The time difference startTime = julian(startTime); dxTime = deltaT/(60*60*24); %Load in the data if ~iscell(attnFile) attnID = netcdf(attnFile, 'nowrite'); attnTime = singlejd(attnID{'time'}(:), attnID{'time2'}(:)); attnData = attnID{'ATTN_55'}(:); attnData(find(attnData > 100 | attnData < -100)) = NaN; [attnTime, attnData] = nanfill_2(attnTime, attnData); psdID = netcdf(psdFile, 'nowrite'); psdTime = singlejd(psdID{'time'}(:), psdID{'time2'}(:)); psdData = psdID{'SDP_850'}(:); psdData(find(psdData > 1e6 | psdData < -1e6)) = NaN; [psdTime, psdData] = nanfill_2(psdTime, psdData); currID = netcdf(currFile, 'nowrite'); currTime = singlejd(currID{'time'}(:), currID{'time2'}(:)); currU = currID{currEast}(:) * theFactor; currU(find(currU > 1e4)) = NaN; currV = currID{currNorth}(:) * theFactor; currV(find(currV > 1e4)) = NaN; currData = sqrt(currU.^2 + currV.^2); [currTime, currData] = nanfill_2(currTime, currData); tempID = netcdf(tempFile, 'nowrite'); tempTime = singlejd(tempID{'time'}(:), tempID{'time2'}(:)); theTemp = tempID{'T_20'}(:); theTemp(find(theTemp > 1e3 | theTemp < -1e3)) = NaN; [tempTime, theTemp] = nanfill_2(tempTime, theTemp); else attnID = netcdf(attnFile{1}, 'nowrite'); attnTime = singlejd(attnID{'time'}(:), attnID{'time2'}(:)); attnData = attnID{'ATTN_55'}(:); attnData(find(attnData > 100 | attnData < -100)) = NaN; theBads = find(isnan(attnData)); attnTime(theBads) = []; attnData(theBads) = []; if length(attnFile) > 1 attnID2 = netcdf(attnFile{2}, 'nowrite'); attnTime2 = singlejd(attnID2{'time'}(:), attnID2{'time2'}(:)); attnData2 = attnID2{'ATTN_55'}(:); attnData2(find(attnData2 > 100 | attnData2 < -100)) = NaN; theBads = find(isnan(attnData2)); attnTime2(theBads) = []; attnData2(theBads) = []; attnTime = [attnTime(:); attnTime2(:)]; attnData = [attnData(:); attnData2(:)]; [attnTime, I] = sort(attnTime); attnData = attnData(I); end [attnTime, attnData] = nanfill_2(attnTime, attnData); psdID = netcdf(psdFile{1}, 'nowrite'); psdTime = singlejd(psdID{'time'}(:), psdID{'time2'}(:)); psdData = psdID{'SDP_850'}(:); psdData(find(psdData > 1e6 | psdData < -1e6)) = NaN; theBads = find(isnan(psdData)); psdTime(theBads) = []; psdData(theBads) = []; if length(psdFile) > 1 psdID2 = netcdf(psdFile{2}, 'nowrite'); psdTime2 = singlejd(psdID2{'time'}(:), psdID2{'time2'}(:)); psdData2 = psdID2{'SDP_850'}(:); psdData2(find(psdData2 > 1e6 | psdData2 < -1e6)) = NaN; theBads = find(isnan(psdData2)); psdTime2(theBads) = []; psdData2(theBads) = []; psdTime = [psdTime(:); psdTime2(:)]; psdData = [psdData(:); psdData2(:)]; [psdTime, I] = sort(psdTime); psdData = psdData(I); end [psdTime, psdData] = nanfill_2(psdTime, psdData); currID = netcdf(currFile{1}, 'nowrite'); currTime = singlejd(currID{'time'}(:), currID{'time2'}(:)); currU = currID{currEast}(:) * theFactor; currU(find(currU > 1e4)) = NaN; currV = currID{currNorth}(:) * theFactor; currV(find(currV > 1e4)) = NaN; currData = sqrt(currU.^2 + currV.^2); theBads = find(isnan(currData)); currTime(theBads) = []; currData(theBads) = []; currU(theBads) = []; currV(theBads) = []; if length(currFile) > 1 currID2 = netcdf(currFile{2}, 'nowrite'); currTime2 = singlejd(currID2{'time'}(:), currID2{'time2'}(:)); currU2 = currID2{currEast}(:) * theFactor; currU2(find(currU2 > 1e4)) = NaN; currV2 = currID2{currNorth}(:) * theFactor; currV2(find(currV2 > 1e4)) = NaN; currData2 = sqrt(currU2.^2 + currV2.^2); theBads = find(isnan(currData2)); currTime2(theBads) = []; currData2(theBads) = []; currU2(theBads) = []; currV2(theBads) = []; currTime = [currTime(:); currTime2(:)]; currData = [currData(:); currData2(:)]; currU = [currU(:); currU2(:)]; currV = [currV(:); currV2(:)]; [currTime, I] = sort(currTime); currData = currData(I); currU = currU(I); currV = currV(I); end [currTime, currData] = nanfill_2(currTime, currData); tempID = netcdf(tempFile{1}, 'nowrite'); tempTime = singlejd(tempID{'time'}(:), tempID{'time2'}(:)); theTemp = tempID{'T_20'}(:); theTemp(find(theTemp > 1e3 | theTemp < -1e3)) = NaN; theBads = find(isnan(theTemp)); tempTime(theBads) = []; theTemp(theBads) = []; if length(tempFile) > 1 tempID2 = netcdf(tempFile{2}, 'nowrite'); tempTime2 = singlejd(tempID2{'time'}(:), tempID2{'time2'}(:)); theTemp2 = tempID2{'T_20'}(:); theTemp2(find(theTemp2 > 1e3 | theTemp2 < -1e3)) = NaN; theBads = find(isnan(theTemp2)); tempTime2(theBads) = []; theTemp2(theBads) = []; tempTime = [tempTime(:); tempTime2(:)]; theTemp = [theTemp(:); theTemp2(:)]; [tempTime, I] = sort(tempTime); theTemp = theTemp(I); end [tempTime, theTemp] = nanfill_2(tempTime, theTemp); end theFiles = dir(fullfile(targetDirectory, '*.tif')); [fileNames{1:length(theFiles)}] = deal(theFiles.name); goodNames = sort(fileNames); startGreg = gregorian(startTime); startYear = num2str(startGreg(1)); startYear = startYear(3:4); endTime = startTime + (length(goodNames)-1)*dxTime; endGreg = gregorian(endTime); endYear = num2str(endGreg(1)); endYear = endYear(3:4); movieName = ['t' num2str(tripodNumber, '%3.0f') '_' ... num2str(startGreg(2), '%02.0f') startYear '_' ... num2str(endGreg(2), '%02.0f') endYear '.avi']; testMovie = avifile(fullfile(saveDirectory, movieName), 'compression', 'none', ... 'fps', 3); f = figure('position', [50 50 700 671], 'DoubleBuffer', 'on'); Isub = subplot('position', [(50/frameWidth) (250/frameHeight) ... (imageWidth/frameWidth) (imageHeight/frameHeight)]); theAngle = 90 - theOrient; theAngle = theAngle * pi /180; theU = 20*cos(theAngle); theV = -1*20*sin(theAngle); s2 = subplot('position', [(250/frameWidth) (50/frameHeight) ... ((2/3)*imageWidth/frameWidth) ((imageWidth/4)/frameHeight)]); psdAx = gca; thePosition = get(psdAx, 'position'); set(psdAx, 'ylim', [0 50], 'ytick', [0:10:50]) theTicks = [min(dayLimits):1:max(dayLimits)]; set(psdAx, 'xtick', theTicks, 'xlim', dayLimits, 'fontsize', 8) set(psdAx, 'xticklabel', ... {' '; ' '; 'Photo time'; ' '; ' '}); theLabel = ylabel(', mb'); theLabelPosition = get(theLabel, 'position'); set(theLabel, 'horiz', 'left') l = line([0 0], [0 50]); set(l, 'color', 'k') box('on') hold on tPSD = title(' PSDEV, and'); set(tPSD, 'color', 'k', 'fontsize', 10, 'horiz', 'center'); tempAx = axes('position', thePosition); theYTicks = {' /0'; ' /4'; ' /8'; ' /12'; ' /16'; ' /20'}; set(tempAx, 'ylim', [0 20], 'color', 'none', 'xlim', dayLimits, ... 'xtick', [], 'ytick', [0:4:20], 'yticklabel', theYTicks, 'fontsize', 8, ... 'yaxisloc', 'right', 'ycolor', greenColor); ylabel('^oC') theLabel = get(tempAx, 'ylabel'); labPosition = get(theLabel, 'position'); newPosition = labPosition; newPosition(1) = newPosition(1)-0.04; set(theLabel, 'color', greenColor, 'fontsize', 8, 'horiz', 'left', 'position', newPosition); box('off') hold on tTemp = title(' Temperature'); set(tTemp, 'color', greenColor, 'horiz', 'center', 'fontsize', 10); attnAx = axes('position', thePosition); set(attnAx, 'ylim', [0 5], 'ytick', [0:1:5], 'yaxisloc', 'right', 'color', 'none') ylabel('m^-^1, ') set(attnAx, 'xtick', [], 'xlim', dayLimits, 'ycolor', 'b', 'fontsize', 8) theLabel = get(attnAx, 'ylabel'); thisPosition = get(theLabel, 'position'); thisPosition(1) = newPosition(1); set(theLabel, 'color', 'b', 'fontsize', 8, 'horiz', 'right', 'position', thisPosition) box('off') hold on tATTN = title(' Beam Attenuation'); set(tATTN, 'color', 'b', 'horiz', 'center', 'fontsize', 10); currAx = axes('position', thePosition); set(currAx, 'ylim', [0 50], 'color', 'none', 'xlim', dayLimits, ... 'xtick', [], 'ytick', [], 'fontsize', 8) ylabel('cm/s') theLabel = get(currAx, 'ylabel'); set(theLabel, 'color', 'r', 'fontsize', 8, 'horiz', 'right', ... 'position', theLabelPosition) box('on') hold on tCurr = title('Current Speed, '); set(tCurr, 'color', 'r', 'horiz', 'center', 'fontsize', 10) s3 = subplot('position', [(50/frameWidth) (50/frameHeight) ... ((imageWidth/4)/frameWidth) ((imageWidth/4)/frameHeight)]); p = polar_n(0, 20); set(p, 'visible', 'off') hold on %tDir = title('Hour-averaged Current'); tDir = title('Current'); set(tDir, 'color', 'r') theSpot = get(tDir, 'position'); theSpot(2) = -1*theSpot(2); %tDir2 = xlabel('Low-passed Current'); %tDir2 = xlabel('Hour-averaged Current'); %set(tDir2, 'color', 'b', 'position', theSpot) for indexFile = 1:length(goodNames) thisTime = startTime + (indexFile-1)*dxTime; fileName = goodNames{indexFile}; [thePath, shortName, theExt] = fileparts(fileName); if findstr(shortName, '_b') Inew = repmat(0, [371 600 3]); fileName = ' '; else I = imread(fullfile(targetDirectory, fileName), 'tif'); theGreen = mean(I(100:200,1:200,2)); lastBlack = max(find(theGreen < (maxGreen+min(theGreen)))); Inew = I; theSlide = 32 - lastBlack; if theSlide < 0 Inew(:,1:size(I,2)+theSlide+1,:) = I(:,-theSlide:end,:); Inew(:,size(I,2)+theSlide:size(I,2),:) = 0; elseif theSlide == 0 Inew = I; elseif theSlide > 0 Inew(:,theSlide:size(I,2),:) = I(:,1:size(I,2)-theSlide+1,:); Inew(:,1:theSlide,:) = 0; end end %Uniform black strip Inew(:,theStrip:end,:) = 0; subplot(Isub) Iplot = imshow(Inew); hold on t = text(5, 20, ['File: ' fileName]); set(t, 'color', 'w', 'horiz', 'left'); theArrow = quiver(25, 60, theU, theV); set(theArrow, 'linewidth', 2, 'color', 'w') t2 = text(55, 60, 'N'); set(t2, 'color', 'w', 'horiz', 'center', 'fontsize', 12) p = plot([130 - 5*imageWidth/theWidth 130 + 5*imageWidth/theWidth], [350 350], 'w'); t3 = text(130, 360, '10 cm'); set(t3, 'color', 'w', 'horiz', 'center', 'fontsize', 10) subplot(s2) psdPlot = plot(psdTime-thisTime, psdData, 'k', 'parent', psdAx, 'linewidth', 1); hitPSD = value2Index(psdTime, thisTime, 1/24); if ~isnan(hitPSD) & ~isnan(psdData(hitPSD)) psdText = text(-1.3, 43, [num2str(psdData(hitPSD), '%.1f') ' mb '], ... 'parent', currAx, 'color', 'k', 'horiz', 'right'); elseif ~isnan(hitPSD) & ~isnan(nanmean(psdData(hitPSD-2:hitPSD+2))) psdText = text(-1.3, 43, [num2str(nanmean(psdData(hitPSD-2:hitPSD+2)), '%.1f') ... ' mb '], 'parent', currAx, 'color', 'k', 'horiz', 'right'); else psdText = text(-1.8, 43, ' '); end attnPlot = plot(attnTime-thisTime, attnData, 'b', 'parent', attnAx, 'linewidth', 1); hitATTN = value2Index(attnTime, thisTime, 1/24); if ~isnan(hitATTN) & ~isnan(attnData(hitATTN)) attnText = text(-1.3, 39, [num2str(attnData(hitATTN), '%.1f') ' m^-^1 '], ... 'parent', currAx, 'color', 'b', 'horiz', 'right'); elseif ~isnan(hitATTN) & ~isnan(nanmean(attnData(hitATTN-2:hitATTN+2))) attnText = text(-1.3, 39, [num2str(nanmean(attnData(hitATTN-2:hitATTN+2)), ... '%.1f') ' m^-^1 '], ... 'parent', currAx, 'color', 'b', 'horiz', 'right'); else attnText = text(-1.8,39, ' '); end currPlot = plot(currTime-thisTime, currData, 'r', 'parent', currAx, 'linewidth', 1); hitCurr = value2Index(currTime, thisTime, 5/(24*60)); if ~isnan(hitCurr) & ~isnan(currData(hitCurr)) currText = text(-1.3, 47, [num2str(currData(hitCurr), '%.1f') ' cm/s'], ... 'parent', currAx, 'color', 'r', 'horiz', 'right'); elseif ~isnan(hitCurr) & ~isnan(nanmean(currData(hitCurr-2:hitCurr+2))) currText = text(-1.3, 47, [num2str(nanmean(currData(hitCurr-2:hitCurr+2)), ... '%.1f') ' cm/s'], ... 'parent', currAx, 'color', 'r', 'horiz', 'right'); else currText = text(-1.8, 47, ' '); end xlabel([datestr(julian2datenum(thisTime), 0) ' GMT']) hitTemp = value2Index(tempTime, thisTime, 1/24); if ~isnan(hitTemp) & ~isnan(theTemp(hitTemp)) tempText = text(-1.3, 35, [num2str(theTemp(hitTemp), '%.1f') ' ^oC^ '], ... 'parent', currAx, 'color', greenColor, 'horiz', 'right'); elseif ~isnan(hitTemp) & ~isnan(nanmean(theTemp(hitTemp-2:hitTemp+2))) tempText = text(-1.3, 35, [num2str(nanmean(theTemp(hitTemp-2:hitTemp+2)), ... '%.1f') ' ^oC^ '], ... 'parent', currAx, 'color', greenColor, 'horiz', 'right'); else tempText = text(-1.8, 35, ' '); end tempPlot = plot(tempTime - thisTime, theTemp, 'parent', tempAx, 'linewidth', 1); set(tempPlot, 'color', greenColor) subplot(s3) if ~isnan(hitCurr) & ~isnan(currU(hitCurr) + currV(hitCurr)) [theAngle2, theLength2] = cart2pol(currU(hitCurr), currV(hitCurr)); elseif ~isnan(hitCurr) [theAngle2, theLength2] = cart2pol(nanmean(currU(hitCurr-2:hitCurr+2)), ... nanmean(currV(hitCurr-2:hitCurr+2))); else theAngle2 = 0; theLength2 = 0; end q2 = polar_n([0 theAngle2], [0 theLength2]); set(q2, 'clipping', 'off', 'linewidth', 2, 'color', 'r'); %fileName = fullfile(frameDirectory, ['frame' num2str(indexFile, '%03.0f') '.tif']); F = getframe(f); testMovie = addframe(testMovie, F); %imwrite(F.cdata, fileName, 'tif'); delete(Iplot) delete(psdPlot) delete(attnPlot) delete(currPlot) %delete(q) delete(q2) delete(t) delete(psdText) delete(attnText) delete(currText) delete(tempText) delete(theArrow) delete(tempPlot) delete(t3) delete(p) clear I end testMovie = close(testMovie); toc close