How can i read data from a text file with parfor or spmd .i have to read as two workers and to combine the result lastly.please reply soon..
Mostrar comentarios más antiguos
How can i read data from a text file with parfor or spmd .i have to read as two workers and to combine the result lastly.please reply soon..
Respuestas (1)
Edric Ellis
el 21 de Jun. de 2013
Something like this?
spmd
fh = fopen(sprintf('file_%d.txt', labindex), 'rt');
data = fscanf(fh, '%f');
fclose(fh);
gcat(data, 1); % GCAT combines the data
end
2 comentarios
shyni
el 22 de Jun. de 2013
Edric Ellis
el 24 de Jun. de 2013
Looks like your file name is incorrect. You could try adding
spmd
fname = sprintf(...);
fh = fopen(fname, 'rt');
if fh == -1
error('Could not read file: %s', fname);
end
...
end
This will indicate which file couldn't be found.
Categorías
Más información sobre Parallel for-Loops (parfor) en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!