In the folder I sent you, when you run [login to view URL], you will get the output, which was saved in output.text. In [login to view URL], you can see that the main routine/function it calls is gen_obs, which is saved in sub_gen_obs.f90. This is the function that needs to be converted to Matlab mex function (of course, gen_obs calls other routines and functions saved in the other files in the folder). When you build the mex function for gen_obs, you need test it whether it works fine in the Matlab. To do so, you need convert [login to view URL] to Matlab m-file, which of course calls the mex-function you build and run it in Matlab. See whether you get the same result as that saved in output.txt.
Hope this description is clear. Do let me