| MATLAB Application Program Interface | Search  Help Desk |
| matPutString | Examples |
Write character mxArrays into MAT-files
integer*4 function matPutString(mfp, name, str) integer*4 mfp character*(*) name, str
mfp
name
mxArray to write to MAT-file.
str
Character array to write to MAT-file.
matPutString writes the mxArray with the specified name and str to the MAT-file mfp. It returns 0 if successful, and 1 if an error occurs.
If the mxArray does not exist on the MAT-file, it is appended to the end. If an mxArray with the same name already exists in the file, the existing mxArray is replaced with the new mxArray by rewriting the file.
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