필터 지우기
필터 지우기

file Identifier Error in parfor loop

조회 수: 2 (최근 30일)
rahman
rahman 2015년 11월 10일
답변: hyiltiz hyiltiz 2018년 4월 24일
Hi all
I want to write many *.txt file in a parfor loop in MATLAB. I use fopen and fprintf. when I use for-loop, the *.txt files created correctly, but when I use parfor-loop the error "Invalid file identifier. Use fopen to generate a valid file identifier." appeared. This error appears when I use MATLAB on linux OS only. ( when I run it with win7, it works correctly). Is there any idea for this error ?
  댓글 수: 1
Edric Ellis
Edric Ellis 2015년 11월 10일
Please post some minimal code that reproduces the problem you're seeing.

댓글을 달려면 로그인하십시오.

답변 (1개)

hyiltiz hyiltiz
hyiltiz hyiltiz 2018년 4월 24일
fname = 'junk.txt';
[fid, message] = fopen(fname, 'w');
if fid < 0;
fprintf(2, 'failed to open "%s" because "%s"\n', fname, message);
%and here, get out gracefully
end
parfor i=1:5
fprintf(fid, 'hi\n');
end
fclose(fid);
Still happens in Matlab 2018a. Really bothersome, and stupid behavior.

카테고리

Help CenterFile Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by