在Matlab中从大文件中获取数据块
有一个巨大的文件 mask.txt 包含以列格式排列的浮点数(单列约 200 万个数字)我想以 512*512 的块提取数据。如何获取下一个数据块。我已执行以下操作,但这是错误的。
rawData=dlmread('mask.txt');
a1=reshape(rawData(1:262144),512,512);
a2=reshape(rawData(262145:524289),512,512);
该怎么办?请解决问题。谢谢你
There is a huge file mask.txt containing floating point numbers arranged in column format(single column of approx 2 million numbers) I want to extract the data in blocks of 512*512. How do I fetch the next block of data. I have done the following but it is erroneous.
rawData=dlmread('mask.txt');
a1=reshape(rawData(1:262144),512,512);
a2=reshape(rawData(262145:524289),512,512);
What to do? Please resolve the problem. Thanking you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的方法是对的,只是你的数字有问题。你犯了一个典型的错误:没有计算第一个数字。该向量应该来自 [n:n+512^2-1],而不是像您那样来自 [n:n+512^2]。所以要修复它,只需做
You method is correct, it's simply your numbers that's wrong. You did the classical mistake of not counting the first number. The vector should be from [n:n+512^2-1], not [n:n+512^2] as you did. So to fix it, just do