memmapfile and importing big-endian data

1 回表示 (過去 30 日間)
D. Plotnick
D. Plotnick 2017 年 4 月 11 日
コメント済み: D. Plotnick 2017 年 4 月 12 日
I need to import a large mixed-format binary file. This is best done using memmapfile. However, the data has also been written in big-endian.
Short of a time consuming loop through the 50,000 lines of the structure, and all of the associated structure fields, is there any way to reverse the endian-ness of everything that comes out of the Data field from memmapfile?
Alternatively, I could do some gruesome struct2cell juggling.Yuck.
Bottom line: is there a way to reverse the endian-ness of memmapfile? If not, that should be added.

採用された回答

Steven Lord
Steven Lord 2017 年 4 月 12 日
I don't believe you can control whether memmapfile treats the file as little-endian or big-endian. You can use the swapbytes function on the data to flip it between the two endian-nesses.
  1 件のコメント
D. Plotnick
D. Plotnick 2017 年 4 月 12 日
That is what I am currently doing, but it is a very slow operation on the order of 20x+ the time required to do the initial import. There are over 600,000 entries in this file alone, each with multiple entries of mixed format that need to be swapped, and the loop through (or as I have written it, cellfun) is a real drag on the code performance.
Since the importation itself using memmapfile is so fast, there must be a better way of doing this.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMeasurements and Feature Extraction についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by