Borrar filtros
Borrar filtros

file Identifier Error in parfor loop

2 visualizaciones (últimos 30 días)
rahman
rahman el 10 de Nov. de 2015
Respondida: hyiltiz hyiltiz el 24 de Abr. de 2018
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 comentario
Edric Ellis
Edric Ellis el 10 de Nov. de 2015
Please post some minimal code that reproduces the problem you're seeing.

Iniciar sesión para comentar.

Respuestas (1)

hyiltiz hyiltiz
hyiltiz hyiltiz el 24 de Abr. de 2018
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.

Categorías

Más información sobre Parallel for-Loops (parfor) en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by