Fetching blocks of data from a huge file in Matlab
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
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
a2=reshape(rawData(262145:524288),512,512);
精彩评论