One can use the 12th generation International Geomagnetic Reference Model for conversion between geomagnetic and geographic coordinates. This is an useful link..
You can find a matlab code of IGRF mode on the webpage (http://www.mathworks.com/matlabcentral/fileexchange/34388-international-geomagnetic-reference-field--igrf--model/content/igrfline.m).
This prog not able to solve my problem. I just need to convert the geomagnetic coordinates to geographic coordinates. I could not find this in the program.
Kishore, Another program to transform gmag into geo coordinates is found on the web site (http://idlastro.gsfc.nasa.gov/ftp/pro/astro/mag2geo.pro). This code is written in IDL. I think you will be able to understand the contents of this IDL code.
AACGM magnetic coordinates can be converted to geographic using the IDL code found here: http://ampere.jhuapl.edu/code/idl_aacgm.html
I use this code daily, so I'm certain it works. It includes the coefficients for the IGRF that you will need. Follow the instruction readme carefully and make sure to make the necessary modifications to your system path environmental variable.
The IDL code from Atsuki Shinbori, above, is a manual code that requires that you manually update it with the orientation of the approximated magnetic dipole (which has changed a lot since 2002 when the code was made with its default values).
You just need the dipole geographic coordinates found at http://wdc.kugi.kyoto-u.ac.jp/poles/polesexp.html and the convertion matrix found at http://www-ssc.igpp.ucla.edu/personnel/russell/papers/gct1.html/
I attached a simple code in R language that I made some time ago. It converts form geographic to geomagnetic, but for your case you can make some modifications.
As you can see from the link: http://naif.jpl.nasa.gov/naif/toolkit.html
the NASA JPL SPICE has a Matlab version. Actually, using the Matlab version is simpler than the Fortran and C version. After you install it and link to downloaded kernels, you can directly type command lines in your Matlab routine. There is no simply answer to your question since the transformation from Geomagnetic coordinates to geographic coordinates is time dependent. Strictly speaking, the rotation matrix keeps changing every second.
If you have corrected geomagnetic coordinates you may like to use the NASA CGI script http://omniweb.gsfc.nasa.gov/vitmo/cgm_vitmo.html (and see the link "How to get model data from command line" if you want to automate the procedure).
If you have simple concentric dipole geomagnetic coordinates then knowledge of the pole latittude and longitude and three rotation transformations are all that is required.
Another alternative is to install the IRBEM libraries http://virbo.org/IRBEM from ONERA.
There has been a event update to the AACGM that can be found here. There are IDL and C versions of the code. https://engineering.dartmouth.edu/superdarn/aacgm.html
The codes are very simple to use and the author is very responsive to questions if you have problems or things you would like to see added to the model.
why going afar? go to this cites www.ngdc.noaa.gov/geomag/magfield.shtml and wdc.kugi.kyoto-u.ac.jp/igrf/index.html. You only need to supply the geomagnetic coordinates of station of your choice and it will generate for you the geographic coordinates, dip angle e.t.c.
Iqbal, please see the link outlined in my post above if you are using IDL or C. I believe another post detailed an option for Fortran if that is your preferred coding language. If none of these are in the language of your preference, I would consider developing a "wrapper" into the online NDGC tool (link provided in Bolarinwa's response, above).