Extracting data from large file

11 views (last 30 days)
Martin
Martin on 22 Dec 2016
Commented: Martin on 23 Dec 2016
Hi all,
I have been writing code to read data from a binary file. I have gotten to the stage now where I just need to reorganize the data, but I have a question about how to go about the organization.
The binary file contains 1310720 elements, comprising of 20, 256*128 images with real and imaginary data points. When loaded into MATLAB it is a row column vector. I know that the first 512 elements belong to image1, the second to image2...., then finally the twentieth to image twenty. Then the twenty first to image1 and so on.... My question is, how would I go about writing code for this extraction? I have tried writing some in a simple loop, but I haven't yet been able to come up with a way to make it anything but very laborious. Any help would be appreciated.

Accepted Answer

Walter Roberson
Walter Roberson on 22 Dec 2016
Guessing a bit about the format:
temp = reshape(TheVector, 512, 20, []);
images = permute( temp(1:256, :, :), [1 3 2]) + i * permute( temp(257:512, :, :), [1 3 2]);
and then the third dimension would be the image number.
  1 Comment
Martin
Martin on 23 Dec 2016
Thanks a lot, great help. The guess about the structure didn't matter, seeing the logic behind what you posted was more than enough.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!