External Interfaces/API Reference | ![]() ![]() |
Copy character
mxArray
s
from MAT-files
Fortran Syntax
integer*4 function matGetString(mfp, name, str, strlen) integer*4 mfp, strlen character*(*) name, str
Arguments
mfp
Pointer to MAT-file information.
name
mxArray
to get from MAT-file.
str
character
array to read from MAT-file.
strlen
character
array.
Description
matGetString
reads the character
mxArray
with the specified name
into str
from the MAT-file mfp
. It returns zero if successful, and a nonzero value if an error occurs.
matGetString
copies the character
array from mxArray
name
on file mfp
into the character array str
.
Only up to strlen
characters are copied, so ordinarily strlen
is set to the dimension of the character
array to prevent writing past the end of the array. If the character
mxArray
contains several rows, they are copied, one column at a time, into one long character
array.
matGetString
returns 0 if the copy is successful, and 1 if the copy has failed because the mxArray
is not a character
mxArray
, 2 if the length of the character
array exceeds strlen
, and 3 if there is a file read error.
Example
program main integer matOpen, matClose, matPutString integer mfp, stat c mfp = matOpen('foo.mat', 'w') stat = matPutString(mfp,'A','Hello, world') stat = matClose(mfp) c stop end
Then you can go to MATLAB and enter:
load foo
A
A =
Hello, world
![]() | matGetNextMatrix | matOpen | ![]() |