由买买提看人间百态

topics

全部话题 - 话题: hdf5write
(共0页)
r****y
发帖数: 1437
1
来自主题: Mathematics版 - matlab在循环中读写大文件的问题
The filename of your hdf5write to is one fixed filename for all loops,
or the name is different for different j?
I suspect it is the former. If so, just make filename distinctive for each
loop, e.g. fname = [' ', int2str(j), '.hdf']
Another possibility is that file is not closed correctly after you write it.
If it is a temp file, why use hdf5write, just write as mat format?
o**n
发帖数: 1249
2
来自主题: Mathematics版 - matlab在循环中读写大文件的问题
最近用matlab遇到了一个问题,代码简化为
for j=1:N
...
func1(...);
func2(...);
...
end
因为func1要计算出一个很大很多的数据给func2用,我在func1中把数据写到一个上百
MB的文件(hdf5write),然后func2中会读这个文件,再进行计算。
结果我发现这个for循环中会有个别的func2的结果是错的,而且我运行这个代码几次,
每次出错的位置(j)不一样,是随机的。
我猜想是不是matlab读写文件的时候又开了一个线程,由于文件太大,所以有了同步问
题,比如某此循环中,func2算的时候func1写的数据还没有完成。可按理说matlab是
Sequence的语言,不应该有这个问题阿,请大家提点。
(共0页)