MATLAB Application Program Interface | Search  Help Desk |
matGetString | Examples |
Copy character
mxArrays
from MAT-files
integer*4 function matGetString(mfp, name, str, strlen) integer*4 mfp, strlen character*(*) name, str
mfp
name
mxArray
to get from MAT-file.
str
Character
array to read from MAT-file.
strlen
character
array.
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.
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 endThen you can go to MATLAB and enter:
load foo
A
A =
Hello, world