program main c c This is an example of a Fortran program that writes a '.mat' data c file that can be read into MATLAB using the LOAD command. For c more information on .'mat' files, see LOAD in the reference section c of the MATLAB User's Guide. See also the file 'savemat.f' which c contains a subroutine that can be called from your own programs to do c the same thing that this program does. c c c Author: S.N. Bangert 5-31-85 c Revised 5-27-86 SNB c c 20 byte header integer*4 type, mrows, ncols, imagf, namlen c c character string for name (length of name plus one) character name(9)*1 c c double precision data arrays for example double precision rp(100), ip(100) c integer irecw, rwflg c data irecw / 1 / c c fill real and imaginary parts do 10 i=1,100 rp(i) = i ip(i) = 101-i 10 continue c c open file as binary open(unit=1,file='fortran.mat',status='new',form='unformatted', 1 access='direct', recl=1) c c set header variables c IMPORTANT NOTE: The variable TYPE contains information describing what c computer (e.g. PC, Sun, VAX) was used. For Sun use 1000, for a PC c use 0, and for a VAX, 2000. The following is for a PC. type = 0 mrows = 20 ncols = 5 imagf = 1 namlen = 9 c c fill name array name(1) = 'y' name(2) = 'o' name(3) = 'u' name(4) = 'r' name(5) = 'n' name(6) = 'a' name(7) = 'm' name(8) = 'e' name(9) = '\0' c c write data call savemat(type, mrows, ncols, imagf, namlen, name, 1 rp, ip, 1, irecw, rwflg) c close(1) c stop end