User`s manual
6 Importing and Exporting Data
6-26
C
C Copy integer to character string
C
do 20 i=1,ndir
call mxCopyPtrToCharacter(adir(i), names(i), 32)
20 continue
C
write(6,*) 'Directory of Mat-file:'
do 30 i=1,ndir
write(6,*) names(i)
30 continue
C
stat = matClose(mp)
if (stat .ne. 0) then
write(6,*) 'Error closing ''matdemo.mat''.'
stop
end if
C
C-------------------------------------------------------------
C Reopen file and read full arrays.
C-------------------------------------------------------------
C
mp = matOpen('matdemo.mat', 'r')
if (mp .eq. 0) then
write(6,*) 'Can''t open ''matdemo.mat''.'
stop
end if
C
C Read directory.
C
write(6,*) 'Getting full array contents:'
pa = matGetNextMatrix(mp)
do while (pa .ne. 0)
C
C Copy name to character string.
C
name = mxGetName(pa)
write(6,*) 'Retrieved ', name
write(6,*) ' With size ', mxGetM(pa), '-by-', mxGetN(pa)
pa = matGetNextMatrix(mp)