intermittant imwrite permissions error

1 view (last 30 days)
Alison Schroer
Alison Schroer on 14 Mar 2019
Edited: Jan on 15 Mar 2019
I have a script that saves a cropped version of a tif stack but intermitantly throws an error that it is unable to open the file for writing (and I may not have write permissions) in the middle of the 300 frame video (but on a different frame each time when I tried running this segment of the code 10 times.
for i = 1:bf_N_frames
imwrite(bf_vid_rot_crop{ivid}(:,:,i),[tfm_init_user_bf_pathnamestack{ivid},tfm_init_user_bf_filenamestack{ivid},'_cropped',tfm_init_user_bf_vidext{ivid}],'writemode','append');
end
Thanks!

Answers (1)

Jan
Jan on 15 Mar 2019
Edited: Jan on 15 Mar 2019
Maybe your disk is full or a callback of a GUI or timer changed the current directory. Let Matlab help you to identify the problem:
FileName = [tfm_init_user_bf_pathnamestack{ivid}, ...
tfm_init_user_bf_filenamestack{ivid}, ...
'_cropped', tfm_init_user_bf_vidext{ivid}];
for i = 1:bf_N_frames
try
imwrite(bf_vid_rot_crop{ivid}(:,:,i), FileName, 'writemode', 'append');
catch ME
fprintf(2, 'File: %s\n', FileName);
fprintf(2, 'CD: %s\n', cd);
fprintf(2, 'Problem: %s\n', ME.message);
% Perhaps check if this is a timing problem:
pause(0.2);
try
imwrite(bf_vid_rot_crop{ivid}(:,:,i), FileName, 'writemode', 'append');
fprintf(2, 'Retry worked...\n')
catch ME2
error('Failed: %s', ME2.message);
end
end
end
What do you get as message?
By the way, 'tfm_init_user_bf_pathnamestack' is a complicated name for a variable.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Products


Release

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!