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