how can i read unformatted binary file into matlab

6 ビュー (過去 30 日間)
anne ellis
anne ellis 2017 年 6 月 28 日
コメント済み: Walter Roberson 2017 年 7 月 22 日
i have a fortran code which writes a binary file in the following statement
open(21,file=anum('press',itime),form=format_mode)
write(21) rtime,itime,dt,nx0,ny0,nz,deltax,deltay,rlenz
write(21) rw
close(21)
i now want to view the file in matlab, i have tried fread with a variety of options, but i cannot get the date in the format i want it. the variable is rw and represents the pressure at x,y,z. the size of the array should be 256x512x390, so essentially i want to see the data in matlab as say a x array a y array etc with the associated values.
i am really struggling to understand how i can really do this, any guidance will be extremely helpful
  2 件のコメント
Walter Roberson
Walter Roberson 2017 年 7 月 22 日
編集済み: Walter Roberson 2017 年 7 月 22 日
What was the value of format_mode ?
What are the fortran data types of rtime, itime, dt, nx0, ny0, nz, deltax, deltay, rlenz and are they scalars or arrays?
Walter Roberson
Walter Roberson 2017 年 7 月 22 日
I suggest that as a test you create a 3D array with integral values but the same datatype as rw, and write it out to file, and then experiment with retrieving it. For example you could store triples 100*first_index + 10 * second_index + third_index for those from 1 3, 1 to 5, and 1 to 4, so values like 243 at rw(2,4,3) so that in the data you read you can immediately tell how to transform the data into the order needed.

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

回答 (1 件)

Gareth Thomas
Gareth Thomas 2017 年 7 月 22 日
Have you tried using the fread command with the options?

カテゴリ

Help Center および File ExchangeFortran with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by