Thank you for this information . Removing the parfor and using just a for loop , I am still receiving the error , however the code looks a bit different index ToFFFTindexSumdirectory , fspan , dt , freq for m 110 sig zeroslengthzspace , lengthxspace , 75000 for j 1 lengthzspace for i 1 lengthxspace R ' R ' num 2 str 720004000 i 1 Z ' Z ' num 2 str 40004000 j 1 file directory R Z ' Theta 0 Channel 4 . dat ' fid fopenfile , ' r ',' b ' fseekfid , 8 m 17500 , ' bof ' sigj , i , freadfid , 75000 , ' double ' fclosefid sig gpuArraysig sampleFreq 1 dt sampleTime 1 sampleFreq numSamples 2 nextpow 2 lengthsig transformedSignal fft sig powerSpectrum transformedSignal . conjtransformedSignal . numSamples f sampleFreq 2 linspace 0 , 1 , numSamples 2 1 sigfft realpowerSpectrum 1 numSamples 21 sigAmpj , i sigfftindex 3 end end ampInterp interp 2 G , H , Amp , Gq , Hq , ' cubic ' contourfGq 1 , ', Hq , 1 , ampInterp , 160 , ' edgecolor ',' none ' colormap jet colorbar ' FontWeight ',' bold ' title ' Bz VLF ',' FontWeight ',' bold ' xlabel ' X position ',' FontWeight ',' bold ' ylabel ' Z position ',' FontWeight ',' bold ' daspect 2 2 2 mTextBox uicontrol ' style ',' text ' Time num 2 strm 13 e 6 , '% 10 . 2 e ', ' ' setmTextBox , ' String ', Time , ' Position ', 320 730 100 20 , ' fontsize ', 12 , ' BackgroundColor ',' w ' setgca , ' nextplot ', ' replacechildren ',' fontsize ', 12 , ' FontWeight ',' bold ' caxis manual caxis 0 . 004 setgcf , ' Color ',' w ' setgcf , ' Renderer ',' painters ' setgcf , ' Renderer ',' zbuffer ' Mm getframegcf endWhen using a loop with a fixed file , it works just fine . When I am opening and closing multiple files , this is not the case .