| MATLAB Application Program Interface | Search  Help Desk | 
| matGetFull | Examples | 
 
Reads full mxArrays from MAT-files
integer*4 function matGetFull(mfp, name, m, n, pr, pi) integer*4 mfp, m, n, pr, pi character*(*) name
mfp
m
n
name
mxArray to get or put to MAT-file.
pi
pr
mxArrays. This routine provides an easy way to copy a full mxArray out of a MAT-file. It offers an alternative to matGetMatrix, which does not require use of the mxArray structure.
matGetFull reads the named mxArray from the MAT-file pointed to by mfp and places the row dimensions, column dimensions, real array pointer, and imaginary array pointer into the locations specified by m, n, pr, and pi, respectively.
matGetFull returns 0 if successful, and 1 if the named variable can't be found, the named variable is not a full mxArray, or there is a file read error.
matGetFull allocates memory for the real and imaginary arrays using mxCalloc; use mxFree to return the memory when you are done.
If the mxArray is pure real, the imaginary pointer is 0.
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 /
c
    mfp = matOpen('foo.mat','w')
    stat = matPutFull(mfp,'A',3,2,Areal,0)
    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