How can I read Fortran90 binary files in MATLAB?

3 ビュー (過去 30 日間)
dawaske
dawaske 2016 年 8 月 12 日
編集済み: Qu Cao 2016 年 8 月 24 日
Hey guys!
I have a Fortan90 based simulation (compiled with the Linux PGI compiler in case this is important) that stores its results in 2D matrices, which are then exported as binary files. In order to comfortably plot the output from the simulations I need to read those binary files into MATLAB, which is just not happening despite searching Google for several hours and trying all kinds of things :( This is the Fortran code responsible for saving the matrices:
subroutine save_data (x,y,z)
integer, intent(in):: x,y,z
integer::i
real, dimension(x,y):: temp
character(20):: filename = ''
do i=1, z
write(filename,'(a,i3.3,a)') 'output_matrix',i,'.dat'
temp=output(1:x,1:y,i)
open(unit=13, file=filename, action="write", status="replace", form="unformatted")
write(13) temp
close(unit=13)
end do
end subroutine save_data
with x=16, y=26 and z=31 for example. Is it even possible to read those output_matrix.dat-files into MATLAB or do I need to store them differently?
I hope you can help me!

回答 (1 件)

Qu Cao
Qu Cao 2016 年 8 月 24 日
編集済み: Qu Cao 2016 年 8 月 24 日
You can try using 'fread' to read Fortran binary files into MATLAB. The following link should be useful for you:

カテゴリ

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