If you are not passing in any arguments or passing out any results, it is pretty simple. Just replace the "main" line with the "mexFunction" line as you have apparently already done. Suppose the filename is myfunction.cpp, then take these steps:
1) Put myfunction.cpp in a directory that is on the MATLAB path.
2) Make that directory your current directory.
3) Issue the following command at the command line prompt:
> mex myfunction.cpp
That will create the mex function for you. Now you can invoke it just like any other function. During compilation if you get a question about searching for compilers, answer Yes, press Enter, then select the number of the C++ compiler that you have installed and will be using. Note that MATLAB does not come with a C++ compiler, you have to get that and install it yourself separately.
