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!

답변 (1개)

Jan
Jan 2019년 3월 15일
편집: Jan 2019년 3월 15일

0 개 추천

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.

카테고리

도움말 센터 및 File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

제품

릴리스

R2017a

태그

질문:

2019년 3월 14일

편집:

Jan
2019년 3월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by