It appears that you are running out of file handles, because you keep calling matOpen but then don't subsequently call matClose. Most systems impose an upper limit on the number of concurrently open files - it would appear that on your system this limit is 512 - there are already...
matlab,fortran,gfortran,mat-file
As pointed out by Alexander Vogt, the compiler requires -cpp option for the pre-processor to recognize the header file and not to treat it as illegal. Linking requires finitrf.h which is usually located in the <matlabroot>/extern/include and the essential libraries are present in <matlabroot>/bin/<arch>/. But just specifying this does not...
Use M=load(matfile);, then you get a struct with all variables in the matfile. Use f=fieldnames(M) to get a list of all variables in the struct and M.(f{1}) to access the first variable (assuming you have only 1)
You can use matfile with cells as long as you are not trying to index into the actual cells. Remember that cells are still arrays, so you can access each cell using array indexing. For example: >> x = {'this', 'is', 'an', 'example'}; >> x{4} ans = example >> x(4)...