Compilers we support
There is a technical note, which contains a list of compilers along with many addresses and phone numbers for compiler companies. This technical note can be found in pub/tech-support/tech-notes/mxeng1.txt.
MEX-File function examples
Where can I get C MEX-file function examples?
Aside from the many C MEX-file examples, which can be found in the $MATLAB/exter/src directory, other examples can be found in pub/tech-support/tech-notes/mxeng3.txt. and pub/tech-support/tech-notes/mxeng4.txt.
Are there any FORTRAN MEX-file examples?
There are many FORTRAN MEX-file examples which can be found in the $MATLAB/exter/src directory.
How do I write a C++ MEX-file function?
A descripton of how to create C++ MEX-file functions is in a technical note which can be found on the ftp server in pub/tech-support/tech-notes/mxeng5.txt.
Are there any engine examples?
The following is an example of a program that uses the MATLAB Engine to find the Hankel matrix:
#include <stdio.h> #include "engine.h"
main()
{
Engine * ep;
char * buffer;
double userdata[3];
int i;
for (i=0;i<3;i++)
{
printf("Enter element #%d: ",i+1);
scanf("%lf",&userdata[i]);
}
ep=engOpen("setenv DISPLAY puff:0; matlab");
if (ep==NULL)
{
fprintf(stderr,"Error opening MATLAB");
exit(-1);
}
if engPutFull(ep,"mystuff",1,3,userdata,NULL)
fprintf(stderr,"Error entering data into MATLAB");
buffer=mxCalloc(201,sizeof(char));
engOutputBuffer(ep,buffer,200);
if(engEvalString("hankel(mystuff)"))
fprintf(stderr,"Error using hankel");
else
printf("Hankel Matrix was \n%s\n",buffer);
mxFree(buffer);
engClose(ep);
}
Common Problems
Why an I getting a segmentation violation error?
Segmentation violation errors occur when MATLAB tries to write to an area of memory that is not allowed. Some possible causes of this are improper dereferencing of pointers, use of pointers which contain incorrect values, and writing past the end of a dimensioned array. You should check your MEX-file function to see if any of these possibilities are occurring.