I think asking for a coding is not relevant. Anyhow u can go through this link http://in.mathworks.com/matlabcentral/fileexchange/18169-optical-character-recognition-ocr/content/OCR/OCR.m
In this the create templates file u can train ur database.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!