MatData Ver 1.02
No License
MatData 1.02
usage:
call read(filename,varname,var)
call write(filename,varname,var,action)
where "filename" is the string of .mat file's name, "varname" is the string of variable's name stored in .mat file, "var" is the variable's name in Fortran program, which can be any one of the following type: 0~3 dimensions, integer(kind=2) or real(kind=4) variables, or string. Other kind of variables will be supported in future.
"action" is character(len=1), optional variable ('w' or 'a'), which denotes create or append the data file "filename". If the file doesnot exist, it will be created.
Examples to use this module in Fortran 90/95:
If want to output a two-dimensional array Temp(100,200) into matlab data file result.mat, use following code:
use matdata
... ...
call write('result.mat','Temperature',temp,'w')
... ...
When read this data into another variable temp2(100,200), using
... ...
call read('result.mat','Temperature',temp2)
... ...
Since MATLAB is case-sensitive whereas Fortran is not, "varname" shoule be case-sensitive.
When compile this Fortran program, MATLAB supported .dll and .lib files libmat.dll libmat.lib libmx.dll libmx.lib libut.dll
must be in the bin and lib path, and following command line is requried:
f90 ... matdata.f90 ... libmat.lib libmx.lib
------------------------
Update, May 25, 2004:
New functions are added into the module, which include read/write one-dimensional matrix of strings.
For example, in order to read/write character(len=100), dimension(100) :: name into result.mat file,
use following code:
call write('result.mat','name',name,'w')
call read ('result.mat','name',name)
One thing should be noted: because Fortran and Matlab use different way to store string array, the subroutine to read
the string array from .mat file to Fortran array use an un-efficient algorithm, if anyone has new idea to improve it,
please contact with me. And also, with this algorithm, unicode output is invalid, evenif both Fortran and Matlab support
unicode string. I hope someone can help me to find an efficient algorithm to input/output unicode string to/from .mat file.
------------------------
Update, Sep. 24, 2004:
New functions are added to the module, which includes:
1) integer(kind=2) and real(kind=8) (double precision)
2) four-dimensions array for all kinds of data type
In order to read .mat file created by Matlab Ver 7, -V6 option should be used, for example: save -mat -V6 [variable lists]
Cite As
Xianyao Chen (2024). MatData Ver 1.02 (https://www.mathworks.com/matlabcentral/fileexchange/4902-matdata-ver-1-02), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 | New functions are added in the code. |