| External Interfaces/API Reference | ![]() |
Writes full mxArrays into MAT-files
Fortran Syntax
integer*4 function matPutFull(mfp, name, m, n, pr, pi) integer*4 mfp, m, n, pr, pi character*(*) name
Arguments
mfp
Pointer to MAT-file information.
name
mxArray to write to MAT-file.
m
n
pr
pi
Description
Most MATLAB applications work only with full (nonsparse) mxArrays. This routine provides an easy way to write a full mxArray into a MAT-file. It offers an alternative to matPutMatrix, which does not require use of the mxArray structure.
matPutFull writes the mxArray with dimensions m-by-n, real data pr, and imaginary data pi onto the MAT-file mfp with the specified name.
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.
Note
This routine will become obsolete in a future version. Use matPutMatrix, mxSetPr, mxSetPi, mxSetM, and mxSetN instead.
|
Examples
Read the mxArray A from one MAT-file and write it out to another.
program main
integer matOpen,matClose,matPutFull,matGetFull
integer mf1, mf2, stat
integer m, n, pr, pi
mf1 = matOpen('foo.mat','r')
mf2 = matOpen('foo2.mat','w')
stat = matGetFull(mf1,'A',m,n,pr,pi)
stat = matPutFull(mf2,'A',m,n,pr,pi)
stat = matClose(mf1)
stat = matClose(mf2)
c
stop
end
Write a simple real mxArray into a MAT-file. Name the mxArray A and the MAT-file foo.mat.
integer matOpen, matClose, matPutFull
integer mfp, stat
double precision Areal(6)
data Areal / 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 /
data Aimag / 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 /
c
mfp = matOpen('foo.mat','w')
stat = matPutFull(mfp,'A',3,2,Areal,Aimag)
stat = matClose(mfp)
c
stop
end
To test, run the second example; then go to MATLAB and enter:
load foo
A
A =
1 4
2 5
3 6
| matOpen | matPutMatrix | ![]() |