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..
Ältere Kommentare anzeigen
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..
Antworten (1)
Edric Ellis
am 21 Jun. 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 Kommentare
shyni
am 22 Jun. 2013
Edric Ellis
am 24 Jun. 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.
Kategorien
Mehr zu Parallel for-Loops (parfor) finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!